Changeset View
Changeset View
Standalone View
Standalone View
native/data/sqlite-data-handler.js
// @flow | // @flow | ||||
import * as React from 'react'; | import * as React from 'react'; | ||||
import { Alert } from 'react-native'; | import { Alert } from 'react-native'; | ||||
import { useDispatch } from 'react-redux'; | import { useDispatch } from 'react-redux'; | ||||
import { setClientDBStoreActionType } from 'lib/actions/client-db-store-actions.js'; | import { setClientDBStoreActionType } from 'lib/actions/client-db-store-actions.js'; | ||||
import { MediaCacheContext } from 'lib/components/media-cache-provider.react.js'; | import { MediaCacheContext } from 'lib/components/media-cache-provider.react.js'; | ||||
import { convertClientDBReportToClientReportCreationRequest } from 'lib/ops/report-store-ops.js'; | |||||
import { isLoggedIn } from 'lib/selectors/user-selectors.js'; | import { isLoggedIn } from 'lib/selectors/user-selectors.js'; | ||||
import { | import { | ||||
logInActionSources, | logInActionSources, | ||||
type LogInActionSource, | type LogInActionSource, | ||||
} from 'lib/types/account-types.js'; | } from 'lib/types/account-types.js'; | ||||
import { fetchNewCookieFromNativeCredentials } from 'lib/utils/action-utils.js'; | import { fetchNewCookieFromNativeCredentials } from 'lib/utils/action-utils.js'; | ||||
import { getMessageForException } from 'lib/utils/errors.js'; | import { getMessageForException } from 'lib/utils/errors.js'; | ||||
import { convertClientDBThreadInfosToRawThreadInfos } from 'lib/utils/thread-ops-utils.js'; | import { convertClientDBThreadInfosToRawThreadInfos } from 'lib/utils/thread-ops-utils.js'; | ||||
▲ Show 20 Lines • Show All 135 Lines • ▼ Show 20 Lines | if (!loggedIn) { | ||||
return; | return; | ||||
} | } | ||||
(async () => { | (async () => { | ||||
await Promise.all([ | await Promise.all([ | ||||
sensitiveDataHandled, | sensitiveDataHandled, | ||||
mediaCacheContext?.evictCache(), | mediaCacheContext?.evictCache(), | ||||
]); | ]); | ||||
try { | try { | ||||
const { threads, messages, drafts, messageStoreThreads } = | const { threads, messages, drafts, messageStoreThreads, reports } = | ||||
await commCoreModule.getClientDBStore(); | await commCoreModule.getClientDBStore(); | ||||
const threadInfosFromDB = | const threadInfosFromDB = | ||||
convertClientDBThreadInfosToRawThreadInfos(threads); | convertClientDBThreadInfosToRawThreadInfos(threads); | ||||
const reportsFromDb = | |||||
convertClientDBReportToClientReportCreationRequest(reports); | |||||
dispatch({ | dispatch({ | ||||
type: setClientDBStoreActionType, | type: setClientDBStoreActionType, | ||||
payload: { | payload: { | ||||
drafts, | drafts, | ||||
messages, | messages, | ||||
threadStore: { threadInfos: threadInfosFromDB }, | threadStore: { threadInfos: threadInfosFromDB }, | ||||
currentUserID: currentLoggedInUserID, | currentUserID: currentLoggedInUserID, | ||||
messageStoreThreads, | messageStoreThreads, | ||||
reports: reportsFromDb, | |||||
}, | }, | ||||
}); | }); | ||||
} catch (setStoreException) { | } catch (setStoreException) { | ||||
if (isTaskCancelledError(setStoreException)) { | if (isTaskCancelledError(setStoreException)) { | ||||
dispatch({ type: setStoreLoadedActionType }); | dispatch({ type: setStoreLoadedActionType }); | ||||
return; | return; | ||||
} | } | ||||
if (staffCanSee) { | if (staffCanSee) { | ||||
Show All 31 Lines |