Browse Source

expand broadcasting rich message by 1 argument

for stories and post children
renovate/org.robolectric-robolectric-4.x
Austin Huang 4 years ago
parent
commit
10447cd633
No known key found for this signature in database GPG Key ID: 84C23AA04587A91F
  1. 8
      app/src/main/java/awais/instagrabber/managers/DirectMessagesManager.kt
  2. 4
      app/src/main/java/awais/instagrabber/viewmodels/PostViewV2ViewModel.kt
  3. 4
      app/src/main/java/awais/instagrabber/viewmodels/ProfileFragmentViewModel.kt

8
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<RankedRecipient>,
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<String>,
userIds: List<List<String>>,
mediaId: String,
secondId: String?,
itemType: BroadcastItemType,
scope: CoroutineScope,
callback: (() -> Unit)?,

4
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<RankedRecipient>) {
@ -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)
}
}

4
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<RankedRecipient>) {
@ -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)
}
}

Loading…
Cancel
Save