mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-17 19:38:52 +01:00
Tap to retry sending failed SMS
This commit is contained in:
@@ -67,6 +67,7 @@ class ComposeActivity : QkActivity<ComposeViewModel>(), ComposeView {
|
||||
override val copyTextIntent: Subject<Message> = PublishSubject.create()
|
||||
override val forwardMessageIntent: Subject<Message> = PublishSubject.create()
|
||||
override val deleteMessageIntent: Subject<Message> = PublishSubject.create()
|
||||
override val messageClickIntent: Subject<Message> by lazy { messageAdapter.clicks }
|
||||
override val attachmentDeletedIntent: Subject<Uri> by lazy { attachmentAdapter.attachmentDeleted }
|
||||
override val textChangedIntent by lazy { message.textChanges() }
|
||||
override val attachIntent by lazy { attach.clicks() }
|
||||
|
||||
@@ -41,6 +41,7 @@ interface ComposeView : QkView<ComposeState> {
|
||||
val copyTextIntent: Subject<Message>
|
||||
val forwardMessageIntent: Subject<Message>
|
||||
val deleteMessageIntent: Subject<Message>
|
||||
val messageClickIntent: Subject<Message>
|
||||
val attachmentDeletedIntent: Subject<Uri>
|
||||
val textChangedIntent: Observable<CharSequence>
|
||||
val attachIntent: Observable<Unit>
|
||||
|
||||
@@ -68,6 +68,7 @@ class ComposeViewModel(intent: Intent) : QkViewModel<ComposeView, ComposeState>(
|
||||
@Inject lateinit var markUnarchived: MarkUnarchived
|
||||
@Inject lateinit var deleteConversation: DeleteConversation
|
||||
@Inject lateinit var sendMessage: SendMessage
|
||||
@Inject lateinit var retrySending: RetrySending
|
||||
@Inject lateinit var markRead: MarkRead
|
||||
@Inject lateinit var deleteMessage: DeleteMessage
|
||||
|
||||
@@ -285,6 +286,12 @@ class ComposeViewModel(intent: Intent) : QkViewModel<ComposeView, ComposeState>(
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe { conversation -> deleteConversation.execute(conversation.id) }
|
||||
|
||||
view.messageClickIntent
|
||||
.filter { message -> message.isFailedMessage() }
|
||||
.doOnNext { message -> retrySending.execute(message) }
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe()
|
||||
|
||||
// Mark the conversation read, if in foreground
|
||||
Observables.combineLatest(messages, view.activityVisibleIntent, { _, b -> b })
|
||||
.withLatestFrom(conversation, { visible, conversation ->
|
||||
|
||||
@@ -59,6 +59,7 @@ class MessagesAdapter @Inject constructor(
|
||||
private const val TIMESTAMP_THRESHOLD = 10
|
||||
}
|
||||
|
||||
val clicks: Subject<Message> = PublishSubject.create<Message>()
|
||||
val longClicks: Subject<Message> = PublishSubject.create<Message>()
|
||||
|
||||
var data: Pair<Conversation, RealmResults<Message>>? = null
|
||||
@@ -107,11 +108,9 @@ class MessagesAdapter @Inject constructor(
|
||||
if (absViewType != VIEW_TYPE_ME) {
|
||||
val address = people[absViewType - 2]
|
||||
if (!contactMap.containsKey(address)) {
|
||||
val contact = data?.first?.recipients?.mapNotNull { it.contact } // Map the conversation to its contacts
|
||||
contactMap[address] = data?.first?.recipients?.mapNotNull { it.contact } // Map the conversation to its contacts
|
||||
?.firstOrNull { it.numbers.any { PhoneNumberUtils.compare(it.address, address) } } // See if any of the phone numbers match
|
||||
?: Contact(numbers = RealmList(PhoneNumber(address = address))) // Fallback to a fake contact
|
||||
|
||||
contactMap.put(address, contact)
|
||||
}
|
||||
|
||||
view.avatar.contact = contactMap[address]
|
||||
@@ -130,6 +129,7 @@ class MessagesAdapter @Inject constructor(
|
||||
val view = viewHolder.itemView
|
||||
|
||||
RxView.clicks(view).subscribe {
|
||||
clicks.onNext(message)
|
||||
if (selected.contains(message.id)) selected.remove(message.id)
|
||||
else selected.add(message.id)
|
||||
notifyItemChanged(position)
|
||||
|
||||
Reference in New Issue
Block a user