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
327 stars 74 forks source link

Implement websocket to Twake Mail #3157

Open tddang-linagora opened 2 months ago

tddang-linagora commented 2 months ago

Description

At the time of creating this ticket, Twake Mail web updates its email view by listening to notification by Firebase Cloud Messaging (FCM). Per https://github.com/linagora/tmail-flutter/issues/1732, websocket will be integrated. All functionality of FCM for mobile must be kept intact, and FCM integrated source code should be refactored so that websocket can be add with ease.

Implementation details

Sample code ```dart abstract class PushNotificationBaseController { const PushNotificationBaseController(); void consumeState(Stream> newStateStream) { // ... } void _handleStateStream(Either newState) { newState.fold(handleFailureViewState, handleSuccessViewState); } void handleFailureViewState(Failure failure); void handleSuccessViewState(Success success); void mappingTypeStateToAction( Map mapTypeState, AccountId accountId, UserName userName, { bool isForeground = true, Session? session }) { // ... } PushNotificationStateChangeAction? _toFcmAction( TypeName typeName, AccountId accountId, UserName userName, Map mapTypeState, isForeground, {Session? session} ) { // ... } } class FcmMessageController extends PushNotificationBaseController { // ... } class WebSocketController extends PushNotificationBaseController { // ... } ```

DoD

tddang-linagora commented 2 weeks ago
tddang-linagora commented 2 weeks ago