@@ -31,7 +31,6 @@ import com.anytypeio.anytype.core_utils.common.DefaultFileInfo
3131import com.anytypeio.anytype.core_utils.ext.cancel
3232import com.anytypeio.anytype.domain.auth.interactor.GetAccount
3333import com.anytypeio.anytype.domain.base.AppCoroutineDispatchers
34- import com.anytypeio.anytype.domain.base.fold
3534import com.anytypeio.anytype.domain.base.onFailure
3635import com.anytypeio.anytype.domain.base.onSuccess
3736import com.anytypeio.anytype.domain.chats.AddChatMessage
@@ -54,6 +53,7 @@ import com.anytypeio.anytype.domain.notifications.NotificationBuilder
5453import com.anytypeio.anytype.domain.`object`.GetObject
5554import com.anytypeio.anytype.domain.objects.CreateObjectFromUrl
5655import com.anytypeio.anytype.domain.objects.ObjectWatcher
56+ import com.anytypeio.anytype.domain.objects.SetObjectListIsArchived
5757import com.anytypeio.anytype.domain.objects.StoreOfObjectTypes
5858import com.anytypeio.anytype.domain.objects.getTypeOfObject
5959import com.anytypeio.anytype.domain.page.CreateObject
@@ -72,12 +72,8 @@ import com.anytypeio.anytype.presentation.objects.ObjectIcon
7272import com.anytypeio.anytype.presentation.objects.SpaceMemberIconView
7373import com.anytypeio.anytype.presentation.search.GlobalSearchItemView
7474import com.anytypeio.anytype.presentation.spaces.SpaceIconView
75- import com.anytypeio.anytype.presentation.spaces.SpaceSettingsViewModel.Command.ShareInviteLink
7675import com.anytypeio.anytype.presentation.spaces.UiSpaceQrCodeState
7776import com.anytypeio.anytype.presentation.spaces.UiSpaceQrCodeState.SpaceInvite
78- import com.anytypeio.anytype.presentation.spaces.UiSpaceSettingsItem.Icon
79- import com.anytypeio.anytype.presentation.spaces.UiSpaceSettingsItem.Name
80- import com.anytypeio.anytype.presentation.spaces.UiSpaceSettingsState
8177import com.anytypeio.anytype.presentation.spaces.spaceIcon
8278import com.anytypeio.anytype.presentation.util.CopyFileToCacheDirectory
8379import com.anytypeio.anytype.presentation.vault.ExitToVaultDelegate
@@ -132,7 +128,8 @@ class ChatViewModel @Inject constructor(
132128 private val analytics : Analytics ,
133129 private val spaceInviteLinkStore : SpaceInviteLinkStore ,
134130 private val getCurrentInviteAccessLevel : GetCurrentInviteAccessLevel ,
135- private val pinObjectAsWidgetDelegate : PinObjectAsWidgetDelegate
131+ private val pinObjectAsWidgetDelegate : PinObjectAsWidgetDelegate ,
132+ private val setObjectListIsArchived : SetObjectListIsArchived
136133) : BaseViewModel(),
137134 ExitToVaultDelegate by exitToVaultDelegate,
138135 PinObjectAsWidgetDelegate by pinObjectAsWidgetDelegate {
@@ -154,6 +151,9 @@ class ChatViewModel @Inject constructor(
154151 val chatBoxMode = MutableStateFlow <ChatBoxMode >(ChatBoxMode .Default ())
155152 val mentionPanelState = MutableStateFlow <MentionPanelState >(MentionPanelState .Hidden )
156153 val showNotificationPermissionDialog = MutableStateFlow (false )
154+ val showMoveToBinDialog = MutableStateFlow (false )
155+
156+
157157 val canCreateInviteLink = MutableStateFlow (false )
158158 private val spaceAccessType = MutableStateFlow <SpaceAccessType ?>(null )
159159 val errorState = MutableStateFlow <UiErrorState >(UiErrorState .Hidden )
@@ -1523,7 +1523,7 @@ class ChatViewModel @Inject constructor(
15231523 // TODO: Implement edit info functionality
15241524 }
15251525
1526- fun onPin () {
1526+ fun onPinChatAsWidget () {
15271527 viewModelScope.launch(dispatchers.io) {
15281528 pinChat(
15291529 space = vmParams.space,
@@ -1536,12 +1536,35 @@ class ChatViewModel @Inject constructor(
15361536 }
15371537 }
15381538
1539- fun onCopyLink () {
1539+ fun onCopyChatLink () {
15401540 // TODO: Implement copy link functionality
15411541 }
15421542
15431543 fun onMoveToBin () {
1544- // TODO: Implement move to bin functionality
1544+ showMoveToBinDialog.value = true
1545+ }
1546+
1547+ fun onMoveToBinConfirmed () {
1548+ viewModelScope.launch {
1549+ setObjectListIsArchived.async(
1550+ SetObjectListIsArchived .Params (
1551+ targets = listOf (vmParams.ctx),
1552+ isArchived = true
1553+ )
1554+ ).onSuccess {
1555+ Timber .d(" Successfully moved chat to bin" )
1556+ showMoveToBinDialog.value = false
1557+ onBackButtonPressed(isExitingVault = false )
1558+ }.onFailure { e ->
1559+ Timber .e(e, " Error while moving chat to bin" )
1560+ sendToast(" Failed to move chat to bin" )
1561+ showMoveToBinDialog.value = false
1562+ }
1563+ }
1564+ }
1565+
1566+ fun onMoveToBinCancelled () {
1567+ showMoveToBinDialog.value = false
15451568 }
15461569
15471570 fun onMediaPreview (objects : List <Id >, index : Int ) {
0 commit comments