kopia lustrzana https://github.com/ryukoposting/Signal-Android
Fix hidden story behaviour.
rodzic
a0ebb891de
commit
768e170ed4
|
@ -146,7 +146,7 @@ class StoriesLandingFragment :
|
||||||
if (!it.data.isHidden) {
|
if (!it.data.isHidden) {
|
||||||
handleHideStory(it)
|
handleHideStory(it)
|
||||||
} else {
|
} else {
|
||||||
lifecycleDisposable += viewModel.setHideStory(it.data.storyRecipient, it.data.isHidden).subscribe()
|
lifecycleDisposable += viewModel.setHideStory(it.data.storyRecipient, !it.data.isHidden).subscribe()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onShareStory = {
|
onShareStory = {
|
||||||
|
|
|
@ -71,13 +71,13 @@ class StoriesLandingRepository(context: Context) {
|
||||||
|
|
||||||
private fun createStoriesLandingItemData(sender: Recipient, messageRecords: List<MessageRecord>): Observable<StoriesLandingItemData> {
|
private fun createStoriesLandingItemData(sender: Recipient, messageRecords: List<MessageRecord>): Observable<StoriesLandingItemData> {
|
||||||
return Observable.create { emitter ->
|
return Observable.create { emitter ->
|
||||||
fun refresh() {
|
fun refresh(sender: Recipient) {
|
||||||
val itemData = StoriesLandingItemData(
|
val itemData = StoriesLandingItemData(
|
||||||
storyRecipient = sender,
|
storyRecipient = sender,
|
||||||
storyViewState = getStoryViewState(messageRecords),
|
storyViewState = getStoryViewState(messageRecords),
|
||||||
hasReplies = messageRecords.any { SignalDatabase.mms.getNumberOfStoryReplies(it.id) > 0 },
|
hasReplies = messageRecords.any { SignalDatabase.mms.getNumberOfStoryReplies(it.id) > 0 },
|
||||||
hasRepliesFromSelf = messageRecords.any { SignalDatabase.mms.hasSelfReplyInStory(it.id) },
|
hasRepliesFromSelf = messageRecords.any { SignalDatabase.mms.hasSelfReplyInStory(it.id) },
|
||||||
isHidden = Recipient.resolved(messageRecords.first().recipient.id).shouldHideStory(),
|
isHidden = sender.shouldHideStory(),
|
||||||
primaryStory = ConversationMessage.ConversationMessageFactory.createWithUnresolvedData(context, messageRecords.first()),
|
primaryStory = ConversationMessage.ConversationMessageFactory.createWithUnresolvedData(context, messageRecords.first()),
|
||||||
secondaryStory = messageRecords.drop(1).firstOrNull()?.let {
|
secondaryStory = messageRecords.drop(1).firstOrNull()?.let {
|
||||||
ConversationMessage.ConversationMessageFactory.createWithUnresolvedData(context, it)
|
ConversationMessage.ConversationMessageFactory.createWithUnresolvedData(context, it)
|
||||||
|
@ -88,15 +88,15 @@ class StoriesLandingRepository(context: Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
val newRepliesObserver = DatabaseObserver.Observer {
|
val newRepliesObserver = DatabaseObserver.Observer {
|
||||||
refresh()
|
Recipient.live(sender.id).refresh()
|
||||||
}
|
}
|
||||||
|
|
||||||
val recipientChangedObserver = RecipientForeverObserver {
|
val recipientChangedObserver = RecipientForeverObserver {
|
||||||
refresh()
|
refresh(it)
|
||||||
}
|
}
|
||||||
|
|
||||||
ApplicationDependencies.getDatabaseObserver().registerConversationObserver(messageRecords.first().threadId, newRepliesObserver)
|
ApplicationDependencies.getDatabaseObserver().registerConversationObserver(messageRecords.first().threadId, newRepliesObserver)
|
||||||
val liveRecipient = Recipient.live(messageRecords.first().recipient.id)
|
val liveRecipient = Recipient.live(sender.id)
|
||||||
liveRecipient.observeForever(recipientChangedObserver)
|
liveRecipient.observeForever(recipientChangedObserver)
|
||||||
|
|
||||||
emitter.setCancellable {
|
emitter.setCancellable {
|
||||||
|
@ -104,7 +104,7 @@ class StoriesLandingRepository(context: Context) {
|
||||||
liveRecipient.removeForeverObserver(recipientChangedObserver)
|
liveRecipient.removeForeverObserver(recipientChangedObserver)
|
||||||
}
|
}
|
||||||
|
|
||||||
refresh()
|
refresh(sender)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue