-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Filter snooze in folders (#2221)
- Loading branch information
Showing
5 changed files
with
114 additions
and
2 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
app/src/main/java/com/infomaniak/mail/data/cache/mailboxContent/CustomRefreshStrategies.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Infomaniak Mail - Android | ||
* Copyright (C) 2025 Infomaniak Network SA | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package com.infomaniak.mail.data.cache.mailboxContent | ||
|
||
import com.infomaniak.mail.data.models.message.Message | ||
import com.infomaniak.mail.data.models.thread.Thread | ||
import io.realm.kotlin.MutableRealm | ||
import io.realm.kotlin.TypedRealm | ||
|
||
val defaultRefreshStrategy = object : DefaultRefreshStrategy {} | ||
|
||
val inboxRefreshStrategy = object : DefaultRefreshStrategy { | ||
override fun queryFolderThreads(folderId: String, realm: TypedRealm): List<Thread> { | ||
return ThreadController.getInboxThreadsWithSnoozeFilter(withSnooze = false, realm = realm) | ||
} | ||
} | ||
|
||
val snoozeRefreshStrategy = object : DefaultRefreshStrategy { | ||
override fun queryFolderThreads(folderId: String, realm: TypedRealm): List<Thread> { | ||
return ThreadController.getInboxThreadsWithSnoozeFilter(withSnooze = true, realm = realm) | ||
} | ||
|
||
override fun updateExistingMessageWhenAdded(remoteMessage: Message, realm: MutableRealm) { | ||
MessageController.updateMessage(remoteMessage.uid, realm = realm) { localMessage -> | ||
localMessage?.snoozeState = remoteMessage.snoozeState | ||
localMessage?.snoozeEndDate = remoteMessage.snoozeEndDate | ||
localMessage?.snoozeAction = remoteMessage.snoozeAction | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
app/src/main/java/com/infomaniak/mail/data/cache/mailboxContent/RefreshStrategies.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Infomaniak Mail - Android | ||
* Copyright (C) 2025 Infomaniak Network SA | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package com.infomaniak.mail.data.cache.mailboxContent | ||
|
||
import com.infomaniak.mail.data.models.message.Message | ||
import com.infomaniak.mail.data.models.thread.Thread | ||
import io.realm.kotlin.MutableRealm | ||
import io.realm.kotlin.TypedRealm | ||
|
||
interface RefreshStrategy { | ||
fun queryFolderThreads(folderId: String, realm: TypedRealm): List<Thread> | ||
fun updateExistingMessageWhenAdded(remoteMessage: Message, realm: MutableRealm) | ||
} | ||
|
||
interface DefaultRefreshStrategy : RefreshStrategy { | ||
override fun queryFolderThreads(folderId: String, realm: TypedRealm): List<Thread> { | ||
return ThreadController.getThreadsByFolderId(folderId, realm) | ||
} | ||
|
||
override fun updateExistingMessageWhenAdded(remoteMessage: Message, realm: MutableRealm) = Unit | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters