TF-2565: Update iOS store link

This commit is contained in:
HuyNguyen
2024-02-05 09:23:46 +07:00
committed by Dat PHAM HOANG
parent 8a2ccf0822
commit f0ac4ef80a
2 changed files with 125 additions and 122 deletions
+32 -29
View File
@@ -1,8 +1,9 @@
const androidStore = 'https://play.google.com/store/apps/details?id=com.linagora.android.teammail'; const androidStore = 'https://play.google.com/store/apps/details?id=com.linagora.android.teammail';
const iosStore = 'https://apps.apple.com/vn/app/twake-mail/id1587086189'; const iosStore = 'https://apps.apple.com/app/twake-mail/id1587086189';
const iosPlatform = 'iOS'; const iosPlatform = 'iOS';
const androidPlatform = 'android'; const androidPlatform = 'android';
const otherPlatform = 'other'; const otherPlatform = 'other';
const timeoutDuration = 4000;
var serviceWorkerVersion = null; var serviceWorkerVersion = null;
var scriptLoaded = false; var scriptLoaded = false;
@@ -18,7 +19,7 @@ function loadMainDartJs() {
} }
function fetchServiceWorker() { function fetchServiceWorker() {
if ('serviceWorker' in navigator) { if ('serviceWorker' in navigator) {
// Service workers are supported. Use them. // Service workers are supported. Use them.
// Wait for registration to finish before dropping the <script>tag. // Wait for registration to finish before dropping the <script>tag.
// Otherwise, the browser will load the script multiple times, // Otherwise, the browser will load the script multiple times,
@@ -67,21 +68,20 @@ if ('serviceWorker' in navigator) {
); );
loadMainDartJs(); loadMainDartJs();
} }
}, 4000); }, timeoutDuration);
} } else {
else {
// Service workers not supported. Just drop the <script> tag. // Service workers not supported. Just drop the <script> tag.
loadMainDartJs(); loadMainDartJs();
} }
} }
function handleContinueTwakeMailOnWeb() { function handleContinueTwakeMailOnWeb() {
console.info('[TwakeMail] handleContinueTwakeMailOnWeb(): Continue on web.'); console.info('[TwakeMail] handleContinueTwakeMailOnWeb(): Continue on web.');
closeBottomSheet(); closeBottomSheet();
fetchServiceWorker(); fetchServiceWorker();
} }
function getPlatform() { function getPlatform() {
console.info('[TwakeMail] getPlatform(): ', navigator.userAgent); console.info('[TwakeMail] getPlatform(): ', navigator.userAgent);
if (/iPhone|iPad|iPod/i.test(navigator.userAgent)) { if (/iPhone|iPad|iPod/i.test(navigator.userAgent)) {
return iosPlatform; return iosPlatform;
@@ -90,47 +90,50 @@ if ('serviceWorker' in navigator) {
return androidPlatform; return androidPlatform;
} }
return otherPlatform; return otherPlatform;
} }
function hanldeOpenTwakeMailApp() { function handleOpenTwakeMailApp() {
const os = getPlatform(); const os = getPlatform();
console.info('[TwakeMail] hanldeOpenTwakeMailApp() - OS:', os); console.info('[TwakeMail] handleOpenTwakeMailApp() - OS:', os);
if (os === androidPlatform) { if (os === androidPlatform) {
document.location.replace(androidStore); document.location.replace(androidStore);
} else if (os === iosPlatform) { } else if (os === iosPlatform) {
document.location.replace(iosStore); document.location.replace(iosStore);
} }
} }
function initialWorkerService() { function initialWorkerService() {
const os = getPlatform(); const os = getPlatform();
const searchParams = Object.fromEntries( const originInUrl = window.location;
new URLSearchParams(window.location.search),
); console.info('[TwakeMail] initialWorkerService(): OriginInUrl:', originInUrl);
const originInUrl = searchParams.origin;
// For desktop, we don't show the open on app popup // For desktop, we don't show the open on app popup
if (os === otherPlatform || typeof window === 'undefined') { if (os === otherPlatform || typeof window === 'undefined') {
if (os !== otherPlatform) {
console.log('[TwakeMail] initialWorkerService(): Keep on browser because:', {
os,
originInUrl,
windowUndefined: typeof window === 'undefined',
});
}
fetchServiceWorker(); fetchServiceWorker();
return; return;
} }
console.log('[TwakeMail] initialWorkerService(): Open the bottom sheet.');
if (window.location.pathname.includes('/login')) {
console.info('[TwakeMail] initialWorkerService(): Login callback');
handleContinueTwakeMailOnWeb();
} else {
openBottomSheet();
}
}
function openBottomSheet() {
console.info('[TwakeMail] openBottomSheet(): Open the bottom sheet.');
const bottomSheet = document.querySelector(".bottom-sheet"); const bottomSheet = document.querySelector(".bottom-sheet");
bottomSheet.style.display = "block"; bottomSheet.style.display = "block";
document.body.style.overflow = "hidden"; document.body.style.overflow = "hidden";
bottomSheet.style.bottom = "0"; bottomSheet.style.bottom = "0";
} }
function closeBottomSheet() { function closeBottomSheet() {
console.info('[TwakeMail] closeBottomSheet(): Closing the bottom sheet.'); console.info('[TwakeMail] closeBottomSheet(): Closing the bottom sheet.');
const bottomSheet = document.querySelector(".bottom-sheet"); const bottomSheet = document.querySelector(".bottom-sheet");
bottomSheet.style.display = "none"; bottomSheet.style.display = "none";
document.body.style.overflow = "auto"; document.body.style.overflow = "auto";
bottomSheet.style.bottom = "-100%"; bottomSheet.style.bottom = "-100%";
} }