AttachmentsPickerViewModel

class AttachmentsPickerViewModel @JvmOverloads constructor(storageHelper: AttachmentStorageHelper, channelState: StateFlow<ChannelState?>, savedStateHandle: SavedStateHandle = SavedStateHandle()) : ViewModel

ViewModel for the attachment picker. Drives picker tab state, device storage browsing, and the isSelected checkmarks shown in attachments.

Note: attachments reflects only the checkmark selection, not the full attachment list staged for the message. The composer attachment list is owned by MessageComposerViewModel.

The active tab and checkmark selection survive process death (e.g. "Don't keep activities"). Checkmarks are not reset on hide — they persist until the session is explicitly consumed (e.g. after a message is sent, a poll is created, or a command is selected).

Parameters

storageHelper

Provides device storage queries and attachment conversion.

channelState

Provides the current ChannelState for channel-specific configuration.

savedStateHandle

Persists picker tab and selection state across process death.

Constructors

Link copied to clipboard
constructor(storageHelper: AttachmentStorageHelper, channelState: StateFlow<ChannelState?>, savedStateHandle: SavedStateHandle = SavedStateHandle())

Properties

Link copied to clipboard

The attachment list for the active pickerMode, with each item's AttachmentPickerItemState.isSelected reflecting the current picker selection.

Link copied to clipboard

The current Channel information.

Link copied to clipboard

Whether the attachment picker is currently visible.

Link copied to clipboard

The active picker tab.

Link copied to clipboard

One-shot events for attachments resolved from system picker URIs. Collected by the parent composable to submit attachments and show error toasts.

Functions

Link copied to clipboard
open fun addCloseable(closeable: AutoCloseable)
fun addCloseable(key: String, closeable: AutoCloseable)
Link copied to clipboard

Converts the given metaData into lightweight Attachments ready to be staged in the composer.

Link copied to clipboard
Link copied to clipboard

Loads attachment metadata from device storage for the current pickerMode.

Link copied to clipboard

Resolves uris from a system picker into Attachments and emits the result via submittedAttachments.

Link copied to clipboard

Switches the active picker tab.

Link copied to clipboard

Shows or hides the attachment picker. Hiding clears cached media data but preserves the current selection so checkmarks remain when the picker is reopened.

Link copied to clipboard

Toggles the attachment picker visibility.