Merge branch 'fix-notification-spam' into dev

This commit is contained in:
nielsandriesse
2020-07-08 11:31:07 +10:00
33 changed files with 841 additions and 665 deletions

View File

@@ -78,7 +78,7 @@ class HomeActivity : PassphraseRequiredActionBarActivity, ConversationClickListe
val threadID = archivedConversations.getLong(archivedConversations.getColumnIndex(ThreadDatabase.ID))
AsyncTask.execute {
threadDatabase.deleteConversation(threadID)
MessageNotifier.updateNotification(this)
(applicationContext as ApplicationContext).messageNotifier.updateNotification(this)
}
}
deleteThreadAtCurrentPosition()
@@ -314,7 +314,7 @@ class HomeActivity : PassphraseRequiredActionBarActivity, ConversationClickListe
ApplicationContext.getInstance(activity).lokiPublicChatAPI!!.leave(publicChat.channel, publicChat.server)
}
threadDatabase.deleteConversation(threadID)
MessageNotifier.updateNotification(activity)
ApplicationContext.getInstance(activity).messageNotifier.updateNotification(activity)
}
}
}

View File

@@ -20,6 +20,24 @@ class LokiPublicChatManager(private val context: Context) {
private val observers = mutableMapOf<Long, ContentObserver>()
private var isPolling = false
public fun areAllCaughtUp():Boolean {
var areAllCaughtUp = true
refreshChatsAndPollers()
for ((threadID, chat) in chats) {
val poller = pollers[threadID] ?: LokiPublicChatPoller(context, chat)
areAllCaughtUp = areAllCaughtUp && poller.isCaughtUp
}
return areAllCaughtUp
}
public fun markAllAsNotCaughtUp() {
refreshChatsAndPollers()
for ((threadID, chat) in chats) {
val poller = pollers[threadID] ?: LokiPublicChatPoller(context, chat)
poller.isCaughtUp = false
}
}
public fun startPollersIfNeeded() {
refreshChatsAndPollers()

View File

@@ -34,6 +34,7 @@ import java.util.*
class LokiPublicChatPoller(private val context: Context, private val group: LokiPublicChat) {
private val handler = Handler()
private var hasStarted = false
public var isCaughtUp = false
// region Convenience
private val userHexEncodedPublicKey = TextSecurePreferences.getLocalNumber(context)
@@ -249,6 +250,7 @@ class LokiPublicChatPoller(private val context: Context, private val group: Loki
processIncomingMessage(message)
}
}
isCaughtUp = true
}.fail {
Log.d("Loki", "Failed to get messages for group chat with ID: ${group.channel} on server: ${group.server}.")
}