Hook back into the app
This commit is contained in:
@@ -202,7 +202,7 @@ export default function App({ Component, pageProps }: AppProps) {
|
||||
}
|
||||
const loadMlSearchState = async () => {
|
||||
try {
|
||||
const enabled = await isFaceIndexingEnabled();
|
||||
const enabled = isFaceIndexingEnabled();
|
||||
setMlSearchEnabled(enabled);
|
||||
mlWorkManager.setMlSearchEnabled(enabled);
|
||||
} catch (e) {
|
||||
@@ -302,7 +302,7 @@ export default function App({ Component, pageProps }: AppProps) {
|
||||
const showNavBar = (show: boolean) => setShowNavBar(show);
|
||||
const updateMlSearchEnabled = async (enabled: boolean) => {
|
||||
try {
|
||||
await setIsFaceIndexingEnabled(enabled);
|
||||
setIsFaceIndexingEnabled(enabled);
|
||||
setMlSearchEnabled(enabled);
|
||||
mlWorkManager.setMlSearchEnabled(enabled);
|
||||
} catch (e) {
|
||||
|
||||
@@ -215,17 +215,16 @@ export const canEnableFaceIndexing = async () =>
|
||||
* on any client. This {@link isFaceIndexingEnabled} property, on the other
|
||||
* hand, denotes whether or not indexing is enabled on the current client.
|
||||
*/
|
||||
export const isFaceIndexingEnabled = async () => {
|
||||
return localStorage.getItem("faceIndexingEnabled") == "1";
|
||||
};
|
||||
export const isFaceIndexingEnabled = () =>
|
||||
localStorage.getItem("faceIndexingEnabled") == "1";
|
||||
|
||||
/**
|
||||
* Update the (locally stored) value of {@link isFaceIndexingEnabled}.
|
||||
*/
|
||||
export const setIsFaceIndexingEnabled = async (enabled: boolean) => {
|
||||
if (enabled) localStorage.setItem("faceIndexingEnabled", "1");
|
||||
else localStorage.removeItem("faceIndexingEnabled");
|
||||
};
|
||||
export const setIsFaceIndexingEnabled = (enabled: boolean) =>
|
||||
enabled
|
||||
? localStorage.setItem("faceIndexingEnabled", "1")
|
||||
: localStorage.removeItem("faceIndexingEnabled");
|
||||
|
||||
/**
|
||||
* Sync face DB with the local (and potentially indexable) files that we know
|
||||
|
||||
@@ -32,9 +32,7 @@ export const getDefaultOptions = async () => {
|
||||
return [
|
||||
// TODO-ML(MR): Skip this for now if indexing is disabled (eventually
|
||||
// the indexing status should not be tied to results).
|
||||
...((await isFaceIndexingEnabled())
|
||||
? [await getIndexStatusSuggestion()]
|
||||
: []),
|
||||
...(isFaceIndexingEnabled() ? [await getIndexStatusSuggestion()] : []),
|
||||
...(await convertSuggestionsToOptions(await getAllPeopleSuggestion())),
|
||||
].filter((t) => !!t);
|
||||
};
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import { faceWorker } from "@/new/photos/services/face";
|
||||
import { fetchAndSaveFeatureFlagsIfNeeded } from "@/new/photos/services/feature-flags";
|
||||
import { clipService } from "services/clip-service";
|
||||
import { syncCLIPEmbeddings } from "services/embeddingService";
|
||||
import { syncEntities } from "services/entityService";
|
||||
import { syncMapEnabled } from "services/userService";
|
||||
import { isFaceIndexingEnabled } from "./face/indexer";
|
||||
|
||||
/**
|
||||
* Perform a soft "refresh" by making various API calls to fetch state from
|
||||
@@ -20,9 +22,7 @@ export const sync = async () => {
|
||||
const electron = globalThis.electron;
|
||||
if (electron) {
|
||||
await syncCLIPEmbeddings();
|
||||
// TODO-ML(MR): Disable fetch until we start storing it in the
|
||||
// same place as the local ones.
|
||||
// if (isFaceIndexingEnabled()) await syncFaceEmbeddings();
|
||||
if (isFaceIndexingEnabled()) await (await faceWorker()).sync();
|
||||
}
|
||||
if (clipService.isPlatformSupported()) {
|
||||
void clipService.scheduleImageEmbeddingExtraction();
|
||||
|
||||
Reference in New Issue
Block a user