Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

use pDebounce for search and fix issues

Abhinav59a0d7c233a6
diff --git a/apps/photos/package.json b/apps/photos/package.json
index 0d5381c817..e3f5236856 100644
--- a/apps/photos/package.json
+++ b/apps/photos/package.json
@@ -51,6 +51,7 @@
"ml-matrix": "^6.10.4",
"next-transpile-modules": "^10.0.0",
"otpauth": "^9.0.2",
+ "p-debounce": "^4.0.0",
"p-queue": "^7.1.0",
"photoswipe": "file:./thirdparty/photoswipe",
"piexifjs": "^1.0.6",
diff --git a/apps/photos/src/components/Search/SearchBar/searchInput/index.tsx b/apps/photos/src/components/Search/SearchBar/searchInput/index.tsx
index 6fa2a3e381..8e2b04a337 100644
--- a/apps/photos/src/components/Search/SearchBar/searchInput/index.tsx
+++ b/apps/photos/src/components/Search/SearchBar/searchInput/index.tsx
@@ -1,5 +1,5 @@
import { IconButton } from '@mui/material';
-import debounce from 'debounce';
+import pDebounce from 'p-debounce';
import { AppContext } from 'pages/_app';
import React, {
useCallback,
@@ -83,7 +83,7 @@ export default function SearchInput(props: Iprops) {
}
};
- const getOptions = debounce(
+ const getOptions = pDebounce(
getAutoCompleteSuggestions(props.files, props.collections),
250
);
diff --git a/apps/photos/src/services/watchFolder/watchFolderService.ts b/apps/photos/src/services/watchFolder/watchFolderService.ts
index f1fe3e3597..f46dd5bd1c 100644
--- a/apps/photos/src/services/watchFolder/watchFolderService.ts
+++ b/apps/photos/src/services/watchFolder/watchFolderService.ts
@@ -37,6 +37,11 @@ class watchFolderService {
private setCollectionName: (collectionName: string) => void;
private syncWithRemote: () => void;
private setWatchFolderServiceIsRunning: (isRunning: boolean) => void;
+ private debouncedRunNextEvent: () => void;
+
+ constructor() {
+ this.debouncedRunNextEvent = debounce(() => this.runNextEvent(), 1000);
+ }
isUploadRunning() {
return this.uploadRunning;
@@ -160,7 +165,7 @@ class watchFolderService {
pushEvent(event: EventQueueItem) {
this.eventQueue.push(event);
- debounce(async () => await this.runNextEvent(), 300)();
+ this.debouncedRunNextEvent();
}
async pushTrashedDir(path: string) {