move syncMapEnabled logic to user service

This commit is contained in:
Abhinav 2023-06-29 20:24:18 +05:30
parent f4bdbc539a
commit 17a924f9e5
2 changed files with 14 additions and 5 deletions

View file

@ -37,11 +37,10 @@ import {
justSignedUp,
setIsFirstLogin,
setJustSignedUp,
setMapEnabled,
} from 'utils/storage';
import {
getMapEnabledStatus,
isTokenValid,
syncMapEnabled,
validateKey,
} from 'services/userService';
import { useDropzone } from 'react-dropzone';
@ -585,8 +584,7 @@ export default function Gallery() {
await syncHiddenFiles(hiddenCollections, setHiddenFiles);
await syncTrash(collections, setTrashedFiles);
await syncEntities();
const mapEnabled = await getMapEnabledStatus();
setMapEnabled(mapEnabled);
await syncMapEnabled();
} catch (e) {
switch (e.message) {
case ServerErrorCodes.SESSION_EXPIRED:

View file

@ -28,6 +28,7 @@ import { B64EncryptionResult } from 'types/crypto';
import { getLocalFamilyData, isPartOfFamily } from 'utils/user/family';
import { AxiosResponse } from 'axios';
import { APPS, getAppName } from 'constants/apps';
import { setMapEnabled } from 'utils/storage';
const ENDPOINT = getEndpoint();
@ -453,7 +454,17 @@ export const updateFaceSearchEnabledStatus = async (newStatus: boolean) => {
}
};
export const getMapEnabledStatus = async () => {
export const syncMapEnabled = async () => {
try {
const status = await getMapEnabledStatus();
setMapEnabled(status);
} catch (e) {
logError(e, 'failed to sync map enabled status');
throw e;
}
};
const getMapEnabledStatus = async () => {
try {
const token = getToken();
const resp: AxiosResponse<GetRemoteStoreValueResponse> =