diff --git a/app/src/main/java/awais/instagrabber/managers/DirectMessagesManager.kt b/app/src/main/java/awais/instagrabber/managers/DirectMessagesManager.kt index bd56b2b1..b1b4685c 100644 --- a/app/src/main/java/awais/instagrabber/managers/DirectMessagesManager.kt +++ b/app/src/main/java/awais/instagrabber/managers/DirectMessagesManager.kt @@ -68,20 +68,21 @@ object DirectMessagesManager { suspend fun createThread(userPk: Long): DirectThread = DirectMessagesService.createThread(csrfToken, viewerId, deviceUuid, listOf(userPk), null) - fun sendMedia(recipient: RankedRecipient, mediaId: String, itemType: BroadcastItemType, scope: CoroutineScope) { - sendMedia(setOf(recipient), mediaId, itemType, scope) + fun sendMedia(recipient: RankedRecipient, mediaId: String, secondId: String?, itemType: BroadcastItemType, scope: CoroutineScope) { + sendMedia(setOf(recipient), mediaId, secondId, itemType, scope) } fun sendMedia( recipients: Set, mediaId: String, + secondId: String?, itemType: BroadcastItemType, scope: CoroutineScope, ) { val threadIds = recipients.mapNotNull{ it.thread?.threadId } val userIdsTemp = recipients.mapNotNull{ it.user?.pk } val userIds = userIdsTemp.map{ listOf(it.toString(10)) } - sendMedia(threadIds, userIds, mediaId, itemType, scope) { + sendMedia(threadIds, userIds, mediaId, secondId, itemType, scope) { inboxManager.refresh(scope) } } @@ -90,6 +91,7 @@ object DirectMessagesManager { threadIds: List, userIds: List>, mediaId: String, + secondId: String?, itemType: BroadcastItemType, scope: CoroutineScope, callback: (() -> Unit)?, diff --git a/app/src/main/java/awais/instagrabber/viewmodels/PostViewV2ViewModel.kt b/app/src/main/java/awais/instagrabber/viewmodels/PostViewV2ViewModel.kt index 51f12618..e8dbd563 100644 --- a/app/src/main/java/awais/instagrabber/viewmodels/PostViewV2ViewModel.kt +++ b/app/src/main/java/awais/instagrabber/viewmodels/PostViewV2ViewModel.kt @@ -336,7 +336,7 @@ class PostViewV2ViewModel : ViewModel() { messageManager = DirectMessagesManager } val mediaId = media.id ?: return - messageManager?.sendMedia(result, mediaId, BroadcastItemType.MEDIA_SHARE, viewModelScope) + messageManager?.sendMedia(result, mediaId, null, BroadcastItemType.MEDIA_SHARE, viewModelScope) } fun shareDm(recipients: Set) { @@ -344,6 +344,6 @@ class PostViewV2ViewModel : ViewModel() { messageManager = DirectMessagesManager } val mediaId = media.id ?: return - messageManager?.sendMedia(recipients, mediaId, BroadcastItemType.MEDIA_SHARE, viewModelScope) + messageManager?.sendMedia(recipients, mediaId, null, BroadcastItemType.MEDIA_SHARE, viewModelScope) } } \ No newline at end of file diff --git a/app/src/main/java/awais/instagrabber/viewmodels/ProfileFragmentViewModel.kt b/app/src/main/java/awais/instagrabber/viewmodels/ProfileFragmentViewModel.kt index 8594212d..bc0e185b 100644 --- a/app/src/main/java/awais/instagrabber/viewmodels/ProfileFragmentViewModel.kt +++ b/app/src/main/java/awais/instagrabber/viewmodels/ProfileFragmentViewModel.kt @@ -214,7 +214,7 @@ class ProfileFragmentViewModel( messageManager = DirectMessagesManager } val mediaId = profile.value?.data?.pk ?: return - messageManager?.sendMedia(result, mediaId.toString(10), BroadcastItemType.PROFILE, viewModelScope) + messageManager?.sendMedia(result, mediaId.toString(10), null, BroadcastItemType.PROFILE, viewModelScope) } fun shareDm(recipients: Set) { @@ -222,7 +222,7 @@ class ProfileFragmentViewModel( messageManager = DirectMessagesManager } val mediaId = profile.value?.data?.pk ?: return - messageManager?.sendMedia(recipients, mediaId.toString(10), BroadcastItemType.PROFILE, viewModelScope) + messageManager?.sendMedia(recipients, mediaId.toString(10), null, BroadcastItemType.PROFILE, viewModelScope) } }