Await not trigger

This commit is contained in:
Manav Rathi
2024-09-17 21:38:46 +05:30
parent 212ab374ac
commit 69a5795c86
4 changed files with 12 additions and 14 deletions

View File

@@ -105,7 +105,7 @@ import {
getSectionSummaries,
} from "services/collectionService";
import { syncFiles } from "services/fileService";
import { sync, triggerPreFileInfoSync } from "services/sync";
import { preFileInfoSync, sync } from "services/sync";
import { syncTrash } from "services/trashService";
import uploadManager from "services/upload/uploadManager";
import { isTokenValid } from "services/userService";
@@ -720,7 +720,7 @@ export default function Gallery() {
throw new Error(CustomError.SESSION_EXPIRED);
}
!silent && startLoading();
triggerPreFileInfoSync();
await preFileInfoSync();
const collections = await getAllLatestCollections();
const { normalCollections, hiddenCollections } =
await splitNormalAndHiddenCollections(collections);

View File

@@ -1,7 +1,7 @@
import { fetchAndSaveFeatureFlagsIfNeeded } from "@/new/photos/services/feature-flags";
import { triggerFeatureFlagsFetchIfNeeded } from "@/new/photos/services/feature-flags";
import {
isMLSupported,
triggerMLStatusSync,
mlStatusSync,
triggerMLSync,
wipClusterEnable,
} from "@/new/photos/services/ml";
@@ -15,9 +15,9 @@ import { syncMapEnabled } from "services/userService";
/**
* Part 1 of {@link sync}. See TODO below for why this is split.
*/
export const triggerPreFileInfoSync = () => {
fetchAndSaveFeatureFlagsIfNeeded();
if (isMLSupported) triggerMLStatusSync();
export const preFileInfoSync = async () => {
triggerFeatureFlagsFetchIfNeeded();
await Promise.all([isMLSupported && mlStatusSync()]);
};
/**

View File

@@ -34,7 +34,7 @@ let _haveFetched = false;
* the default. Otherwise the now fetched result is saved to local storage
* and the corresponding value returned.
*/
export const fetchAndSaveFeatureFlagsIfNeeded = () => {
export const triggerFeatureFlagsFetchIfNeeded = () => {
if (_haveFetched) return;
if (_fetchTimeout) return;
// Not critical, so fetch these after some delay.

View File

@@ -279,14 +279,12 @@ const updateIsMLEnabledRemote = (enabled: boolean) =>
* It checks with remote if the ML flag is set, and updates our local flag to
* reflect that value.
*
* To trigger the actual ML sync, use {@link triggerMLSync}.
* To perform the actual ML sync, use {@link mlSync}.
*/
export const triggerMLStatusSync = () => void mlStatusSync();
const mlStatusSync = async () => {
export const mlStatusSync = async () => {
_state.isMLEnabled = await getIsMLEnabledRemote();
setIsMLEnabledLocal(_state.isMLEnabled);
triggerStatusUpdate();
return updateMLStatusSnapshot();
};
/**
@@ -298,7 +296,7 @@ const mlStatusSync = async () => {
* If ML is enabled, it pulls any missing embeddings from remote and starts
* indexing to backfill any missing values.
*
* This will only have an effect if {@link triggerMLSync} has been called at
* This will only have an effect if {@link mlStatusSync} has been called at
* least once prior to calling this in the sync sequence.
*/
export const triggerMLSync = () => void mlSync();