linagora / tmail-flutter

A multi-platform (Flutter) application for reading your emails, with your favorite devices, using the JMAP protocol!
GNU Affero General Public License v3.0
319 stars 73 forks source link

Create & handle "Inbox" notification checkbox in Flutter #2880

Open tddang-linagora opened 5 months ago

tddang-linagora commented 5 months ago

Description

Create a checkbox to control Inbox push notification. This checkbox will only appear if the toggle created in #2877 is on, and the checkbox's state will be cache with Hive for Android & Keychain for iOS. When this checkbox is turned on, user will only receive push notification when new email comes to Inbox mailbox. When off, user will receive push notification for every new email from all mailboxes.

Definitions of done

For Android

For iOS

hoangdat commented 5 months ago

please more detail on the technical guideline, how to prevent notification?

tddang-linagora commented 4 months ago

Entitlement needed

tddang-linagora commented 4 months ago

@hoangdat @dab246 Should we save the setting for each user and restore that setting when user login or whenever user is log out, this setting will be cleared?

hoangdat commented 4 months ago

@hoangdat @dab246 Should we save the setting for each user and restore that setting when user login or whenever user is log out, this setting will be cleared?

IMO, still a good choice to still save this settings event user logout. How about keychain item if we delete app in iOS?

tddang-linagora commented 4 months ago

How about keychain item if we delete app in iOS?

The user's data persists even after the app is deleted if we use Keychain. If that's not what we want, changing the iOS's storage of choice from Keychain to SharedPreferences is better.

hoangdat commented 4 months ago

if we change to SharedPreference how to prevent notification in NSE?

tddang-linagora commented 4 months ago

if we change to SharedPreference how to prevent notification in NSE?

Instead of from Keychain, we will get the user's data from NSUserDefaults if SharedPreferences is used. Either case, an entitlement has to be added to prevent notification in NSE. see this comment

dab246 commented 4 months ago

IMO, we should use Hive database, which is better stored as objects rather than as primitive variables in SharePreference

tddang-linagora commented 4 months ago

IMO, we should use Hive database, which is better stored as objects rather than as primitive variables in SharePreference

I only intend to store a boolean so Hive is a bit overkill.

dab246 commented 4 months ago

IMO, we should use Hive database, which is better stored as objects rather than as primitive variables in SharePreference

I only intend to store a boolean so Hive is a bit overkill.

So how does it support multiple accounts? How to manage it?

tddang-linagora commented 4 months ago

So how does it support multiple accounts? How to manage it?

Data is saved with SharedPreferences using key-value pair. The key is where I intend to separate those values. E.g. The form of the key might take is "accountId-mailboxRole"

dab246 commented 4 months ago

So how does it support multiple accounts? How to manage it?

Data is saved with SharedPreferences using key-value pair. The key is where I intend to separate those values. E.g. The form of the key might take is "accountId-mailboxRole"

When we want to turn on/off notifications for more mailboxes. We have to create multiple keys for each account then will now have a data table

accountId1-mailboxRole1 : value
accountId1-mailboxRole2 : value
accountId2-mailboxRole1 : value
accountId2-mailboxRole2 : value
accountId3-mailboxRole1 : value
accountId3-mailboxRole2 : value

It can be seen that organizing such data will be very confusing and will be difficult for future developers. IMO, we should organize in a tree style

account1: {
   mailbox1 : value
   mailbox2 : value
}

account2: {
   mailbox1 : value
   mailbox2 : value
}
tddang-linagora commented 4 months ago

we should organize in a tree style

Sure let me update the issue's description

tddang-linagora commented 4 months ago

Few points need to be mentioned

@hoangdat @dab246 what do you think?

dab246 commented 4 months ago

LGTM

hoangdat commented 4 months ago

@tddang-linagora can you try the JMAP requests to detect the email belongs to which mailbox?

hoangdat commented 4 months ago

Android:

hoangdat commented 4 months ago

iOS: