Skip to content

Commit

Permalink
Support Scheduled Send for Recorded Audio
Browse files Browse the repository at this point in the history
  • Loading branch information
Sagar0-0 committed Jan 31, 2025
1 parent 6492a90 commit cb0ae30
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1830,7 +1830,8 @@ class ConversationFragment :
slide: Slide? = null,
contacts: List<Contact> = emptyList(),
quote: QuoteModel? = null,
clearCompose: Boolean = true
clearCompose: Boolean = true,
scheduledDate: Long = -1,
) {
sendMessage(
slideDeck = slide?.let { SlideDeck().apply { addSlide(slide) } },
Expand All @@ -1842,7 +1843,8 @@ class ConversationFragment :
messageToEdit = null,
quote = quote,
linkPreviews = emptyList(),
bypassPreSendSafetyNumberCheck = true
bypassPreSendSafetyNumberCheck = true,
scheduledDate = scheduledDate
)
}

Expand Down Expand Up @@ -1882,6 +1884,7 @@ class ConversationFragment :
}

if (inputPanel.isRecordingInLockedMode) {
viewModel.updateScheduledDate(scheduledDate)
inputPanel.releaseRecordingLock()
return
}
Expand Down Expand Up @@ -3966,7 +3969,7 @@ class ConversationFragment :
}

override fun canSchedule(): Boolean {
return !(inputPanel.isRecordingInLockedMode || draftViewModel.voiceNoteDraft != null)
return draftViewModel.voiceNoteDraft == null
}
}

Expand Down Expand Up @@ -4422,8 +4425,10 @@ class ConversationFragment :

sendMessageWithoutComposeInput(
slide = audioSlide,
scheduledDate = viewModel.scheduledDate,
quote = inputPanel.quote.orNull()
)
viewModel.clearScheduledDate()
}

override fun cancelEphemeralVoiceNoteDraft(draft: VoiceNoteDraft) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ class ConversationViewModel(
var titleViewParticipantsSnapshot: List<Recipient> = emptyList()
private set

@Volatile
var scheduledDate: Long = -1L
private set

val isPushAvailable: Boolean
get() = recipientSnapshot?.isRegistered == true && Recipient.self().isRegistered

Expand Down Expand Up @@ -310,6 +314,14 @@ class ConversationViewModel(
})
}

fun updateScheduledDate(scheduledDate: Long) {
this.scheduledDate = scheduledDate
}

fun clearScheduledDate() {
this.scheduledDate = -1
}

fun getBannerFlows(
context: Context,
groupJoinClickListener: () -> Unit,
Expand Down

0 comments on commit cb0ae30

Please sign in to comment.