Merge pull request #5370 from k9mail/inbox_push_class

Set push class of Inbox to 'first class' by default
This commit is contained in:
cketti 2021-06-26 22:37:50 +02:00 committed by GitHub
commit ec6e976198
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 35 additions and 0 deletions

View file

@ -201,6 +201,11 @@ class FolderRepository(
messageStore.setSyncClass(folderId, folderClass)
}
fun setPushClass(folderId: Long, folderClass: FolderClass) {
val messageStore = messageStoreManager.getMessageStore(account)
messageStore.setPushClass(folderId, folderClass)
}
fun setNotificationClass(folderId: Long, folderClass: FolderClass) {
val messageStore = messageStoreManager.getMessageStore(account)
messageStore.setNotificationClass(folderId, folderClass)

View file

@ -36,6 +36,11 @@ class ListenableMessageStore(private val messageStore: MessageStore) : MessageSt
notifyFolderSettingsChanged()
}
override fun setPushClass(folderId: Long, folderClass: FolderClass) {
messageStore.setPushClass(folderId, folderClass)
notifyFolderSettingsChanged()
}
override fun setNotificationClass(folderId: Long, folderClass: FolderClass) {
messageStore.setNotificationClass(folderId, folderClass)
notifyFolderSettingsChanged()

View file

@ -196,6 +196,11 @@ interface MessageStore {
*/
fun setSyncClass(folderId: Long, folderClass: FolderClass)
/**
* Update the push class of a folder.
*/
fun setPushClass(folderId: Long, folderClass: FolderClass)
/**
* Update the notification class of a folder.
*/

View file

@ -49,6 +49,7 @@ class SpecialFolderUpdater(
folderRepository.setIncludeInUnifiedInbox(newInboxId, true)
folderRepository.setDisplayClass(newInboxId, FolderClass.FIRST_CLASS)
folderRepository.setSyncClass(newInboxId, FolderClass.FIRST_CLASS)
folderRepository.setPushClass(newInboxId, FolderClass.FIRST_CLASS)
folderRepository.setNotificationClass(newInboxId, FolderClass.FIRST_CLASS)
}
}

View file

@ -153,6 +153,10 @@ class K9MessageStore(
updateFolderOperations.setSyncClass(folderId, folderClass)
}
override fun setPushClass(folderId: Long, folderClass: FolderClass) {
updateFolderOperations.setPushClass(folderId, folderClass)
}
override fun setNotificationClass(folderId: Long, folderClass: FolderClass) {
updateFolderOperations.setNotificationClass(folderId, folderClass)
}

View file

@ -53,6 +53,10 @@ internal class UpdateFolderOperations(private val lockableDatabase: LockableData
setString(folderId = folderId, columnName = "poll_class", value = folderClass.name)
}
fun setPushClass(folderId: Long, folderClass: FolderClass) {
setString(folderId = folderId, columnName = "push_class", value = folderClass.name)
}
fun setNotificationClass(folderId: Long, folderClass: FolderClass) {
setString(folderId = folderId, columnName = "notify_class", value = folderClass.name)
}

View file

@ -98,6 +98,17 @@ class UpdateFolderOperationsTest : RobolectricTest() {
assertThat(folder.syncClass).isEqualTo("NO_CLASS")
}
@Test
fun `update push class`() {
val folderId = sqliteDatabase.createFolder(pushClass = "FIRST_CLASS")
updateFolderOperations.setPushClass(folderId = folderId, folderClass = FolderClass.NO_CLASS)
val folder = sqliteDatabase.readFolders().first()
assertThat(folder.id).isEqualTo(folderId)
assertThat(folder.pushClass).isEqualTo("NO_CLASS")
}
@Test
fun `update notification class`() {
val folderId = sqliteDatabase.createFolder(syncClass = "FIRST_CLASS")