mirror of
https://github.com/mattermost/mattermost-mobile.git
synced 2026-11-06 10:50:13 +00:00
* implements auto cache cleanup when zero persistence mode is enabled (0 value)
* uses memory flag with sqlite instead of loki when running in zero persistence mode
* renames ephemeral mode manager and improves readability
* zero persistence refactors and restore values during transitions
* fixes ephemeral mode tests
* use initializeClient instead of just initialize to wait for doReconnect to finish
that way teams loading is awaited while WS reconnects during ZPM transitions
* adds inital sync as a mount hook to prevent undesired load error states
during app cold start in ZPM mode, we need a way to load team and channels
without showing loading error during the transition. The nre is initial sync
hook allows for it
* reset started sync subject on wipe
* removes extra log lines
* resets tracked server during ephemeral mode transitions
* improvements to apply persistence mode changes when something fails
* address coderabbit PR suggestions
* add batching time logging
* throws ephemeral mode change error as is
* make deleteServerDatabaseFiles private
* inline derive persistence flag function
* return current user id when refetching current user
* support zero persistence mode server for push notifications
* adds support for zero persistence mode when sharing to mattermost
* adds clarifying comment
* catch and log error deleting files
* reorder translations to correct position
* adds some new tests to improve coverage
* ios push notification native fix
* logout when fetchMe fails with 401 status code during reconnection
* properly surface errors
* return proper false value when checking for zero persistence flag
* change comments and properly await on some operations
* prevent not set persistence mode to report as an error
* include servers with no persistence flag set in share list
* disable button for accessibility
* improves when to store and remove signing key from global area
* review push notification reception running in zero persistence mode
* add server to ephemeral mode manager right after login
---------
(cherry picked from commit a5ff8a0d95)
Co-authored-by: Carlos Garcia <carlos.garcia@mattermost.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
78 lines
2.7 KiB
TypeScript
78 lines
2.7 KiB
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import {CallsManager} from '@calls/calls_manager';
|
|
import DatabaseManager from '@database/manager';
|
|
import CallsNative from '@init/calls_native';
|
|
import {getAllServerCredentials} from '@init/credentials';
|
|
import ManagedApp from '@init/managed_app';
|
|
import PushNotifications from '@init/push_notifications';
|
|
import EphemeralModeManager from '@managers/ephemeral_mode_manager';
|
|
import GlobalEventHandler from '@managers/global_event_handler';
|
|
import NetworkManager from '@managers/network_manager';
|
|
import SecurityManager from '@managers/security_manager';
|
|
import SessionManager from '@managers/session_manager';
|
|
import WebsocketManager from '@managers/websocket_manager';
|
|
import EphemeralStore from '@store/ephemeral_store';
|
|
import {NavigationStore} from '@store/navigation_store';
|
|
|
|
// Controls whether the main initialization (database, etc...) is done, either on app launch
|
|
// or on the Share Extension, for example.
|
|
let baseAppInitialized = false;
|
|
let serverCredentials: ServerCredential[] = [];
|
|
|
|
// Fallback Polyfill for Promise.allSettle
|
|
Promise.allSettled = Promise.allSettled || (<T>(promises: Array<Promise<T>>) => Promise.all(
|
|
promises.map((p) => p.
|
|
then((value) => ({
|
|
status: 'fulfilled',
|
|
value,
|
|
})).
|
|
catch((reason) => ({
|
|
status: 'rejected',
|
|
reason,
|
|
})),
|
|
),
|
|
));
|
|
|
|
export async function initialize() {
|
|
if (!baseAppInitialized) {
|
|
baseAppInitialized = true;
|
|
serverCredentials = await getAllServerCredentials();
|
|
const serverUrls = serverCredentials.map((credential) => credential.serverUrl);
|
|
|
|
await DatabaseManager.init(serverUrls);
|
|
await NetworkManager.init(serverCredentials);
|
|
|
|
// EphemeralModeManager init runs before WS init so any pending wipes
|
|
// complete before WebSocket clients start populating server databases.
|
|
await EphemeralModeManager.init(serverCredentials);
|
|
await WebsocketManager.init(serverCredentials);
|
|
}
|
|
|
|
NavigationStore.reset();
|
|
EphemeralStore.setCurrentThreadId('');
|
|
EphemeralStore.setProcessingNotification('');
|
|
|
|
await SecurityManager.init();
|
|
|
|
GlobalEventHandler.init();
|
|
ManagedApp.init();
|
|
SessionManager.init();
|
|
CallsManager.initialize();
|
|
CallsNative.init();
|
|
|
|
PushNotifications.init(serverCredentials.length > 0);
|
|
}
|
|
|
|
export function cleanup() {
|
|
ManagedApp.cleanup();
|
|
GlobalEventHandler.cleanup();
|
|
SecurityManager.cleanup();
|
|
SessionManager.cleanup();
|
|
CallsManager.cleanup();
|
|
CallsNative.cleanup();
|
|
PushNotifications.cleanup();
|
|
EphemeralModeManager.cleanup();
|
|
}
|