diff --git a/docs/adr/0008-handle-heavy-task-with-isolate.md b/docs/adr/0008-handle-heavy-task-with-isolate.md index cf4b5c9b0..3db7d3843 100644 --- a/docs/adr/0008-handle-heavy-task-with-isolate.md +++ b/docs/adr/0008-handle-heavy-task-with-isolate.md @@ -36,7 +36,7 @@ isolateManager.execute( - Communicate between two isolates To see a visual representation of this process, take a look at the image below: -[communicate_between_two_isolate](../images/handle_task_with_isolate.png); +communicate_between_two_isolate ## Consequences @@ -45,4 +45,4 @@ To see a visual representation of this process, take a look at the image below: ## Reference -- [worker_manager](https://pub.dev/packages/worker_manager) +- worker_manager diff --git a/docs/adr/0054-update-flutter-service-worker-initialization.md b/docs/adr/0054-update-flutter-service-worker-initialization.md new file mode 100644 index 000000000..66779fba0 --- /dev/null +++ b/docs/adr/0054-update-flutter-service-worker-initialization.md @@ -0,0 +1,24 @@ +# 54. Update Flutter Service Worker Initialization + +Date: 2024-11-15 + +## Status + +Accepted + +## Context + +- Since the new version of Flutter, old initialization of Flutter Service Worker does not work. + - Version is always null + - Twake Mail web resources is requested everytime the web is loaded, no cache is used + - One hard-reload, one normal reload + +## Decision + +- We update the initialization of Flutter Service Worker according to the new version of Flutter +- More reference: https://docs.flutter.dev/platform-integration/web/initialization + +## Consequences + +- Twake Mail web use cache resources to improve performance + - One hard-reload, many normal reload diff --git a/docs/images/after-flutter-3.22.png b/docs/images/after-flutter-3.22.png new file mode 100644 index 000000000..02e04e379 Binary files /dev/null and b/docs/images/after-flutter-3.22.png differ diff --git a/docs/images/before-flutter-3.22.png b/docs/images/before-flutter-3.22.png new file mode 100644 index 000000000..e76dae49d Binary files /dev/null and b/docs/images/before-flutter-3.22.png differ diff --git a/web/index.html b/web/index.html index c54b494cc..7fc5db253 100644 --- a/web/index.html +++ b/web/index.html @@ -99,7 +99,20 @@ application. For more information, see: https://developers.google.com/web/fundamentals/primers/service-workers --> diff --git a/web/worker_service/worker_service.js b/web/worker_service/worker_service.js index ec6a1a7ee..41a7e7930 100644 --- a/web/worker_service/worker_service.js +++ b/web/worker_service/worker_service.js @@ -3,66 +3,10 @@ const iosStore = 'https://apps.apple.com/app/twake-mail/id1587086189'; const iosPlatform = 'iOS'; const androidPlatform = 'android'; const otherPlatform = 'other'; -const timeoutDuration = 4000; -var scriptLoaded = false; - -function loadMainDartJs() { - if (scriptLoaded) { - return; - } - scriptLoaded = true; - var scriptTag = document.createElement('script'); - scriptTag.src = 'main.dart.js'; - scriptTag.type = 'application/javascript'; - document.body.append(scriptTag); -} - -function fetchServiceWorker() { - if ('serviceWorker' in navigator) { - // Service workers are supported. Use them. - // Wait for registration to finish before dropping the