Skip to content

armgit / ente

Public Imported from GitHub
0

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

Rename the type on the electron side

Manav Rathi1fea50979364
diff --git a/desktop/src/main/ipc.ts b/desktop/src/main/ipc.ts
index bd29057da0..a5de4514f9 100644
--- a/desktop/src/main/ipc.ts
+++ b/desktop/src/main/ipc.ts
@@ -10,7 +10,7 @@
import type { FSWatcher } from "chokidar";
import { ipcMain } from "electron/main";
-import type { ElectronFile, FILE_PATH_TYPE, WatchMapping } from "../types/ipc";
+import type { ElectronFile, FILE_PATH_TYPE, FolderWatch } from "../types/ipc";
import {
selectDirectory,
showUploadDirsDialog,
@@ -242,13 +242,13 @@ export const attachFSWatchIPCHandlers = (watcher: FSWatcher) => {
ipcMain.handle(
"updateWatchMappingSyncedFiles",
- (_, folderPath: string, files: WatchMapping["syncedFiles"]) =>
+ (_, folderPath: string, files: FolderWatch["syncedFiles"]) =>
updateWatchMappingSyncedFiles(folderPath, files),
);
ipcMain.handle(
"updateWatchMappingIgnoredFiles",
- (_, folderPath: string, files: WatchMapping["ignoredFiles"]) =>
+ (_, folderPath: string, files: FolderWatch["ignoredFiles"]) =>
updateWatchMappingIgnoredFiles(folderPath, files),
);
};
diff --git a/desktop/src/main/services/watch.ts b/desktop/src/main/services/watch.ts
index 8a3414c58c..1d466d4156 100644
--- a/desktop/src/main/services/watch.ts
+++ b/desktop/src/main/services/watch.ts
@@ -1,6 +1,6 @@
import type { FSWatcher } from "chokidar";
import ElectronLog from "electron-log";
-import { WatchMapping, WatchStoreType } from "../../types/ipc";
+import { FolderWatch, WatchStoreType } from "../../types/ipc";
import { watchStore } from "../stores/watch.store";
export const addWatchMapping = async (
@@ -28,7 +28,7 @@ export const addWatchMapping = async (
setWatchMappings(watchMappings);
};
-function isMappingPresent(watchMappings: WatchMapping[], folderPath: string) {
+function isMappingPresent(watchMappings: FolderWatch[], folderPath: string) {
const watchMapping = watchMappings?.find(
(mapping) => mapping.folderPath === folderPath,
);
@@ -59,7 +59,7 @@ export const removeWatchMapping = async (
export function updateWatchMappingSyncedFiles(
folderPath: string,
- files: WatchMapping["syncedFiles"],
+ files: FolderWatch["syncedFiles"],
): void {
const watchMappings = getWatchMappings();
const watchMapping = watchMappings.find(
@@ -76,7 +76,7 @@ export function updateWatchMappingSyncedFiles(
export function updateWatchMappingIgnoredFiles(
folderPath: string,
- files: WatchMapping["ignoredFiles"],
+ files: FolderWatch["ignoredFiles"],
): void {
const watchMappings = getWatchMappings();
const watchMapping = watchMappings.find(
diff --git a/desktop/src/preload.ts b/desktop/src/preload.ts
index ff2cf505af..2749fa50d2 100644
--- a/desktop/src/preload.ts
+++ b/desktop/src/preload.ts
@@ -45,7 +45,7 @@ import type {
AppUpdateInfo,
ElectronFile,
FILE_PATH_TYPE,
- WatchMapping,
+ FolderWatch,
} from "./types/ipc";
// - General
@@ -220,18 +220,18 @@ const addWatchMapping = (
const removeWatchMapping = (folderPath: string): Promise<void> =>
ipcRenderer.invoke("removeWatchMapping", folderPath);
-const getWatchMappings = (): Promise<WatchMapping[]> =>
+const getWatchMappings = (): Promise<FolderWatch[]> =>
ipcRenderer.invoke("getWatchMappings");
const updateWatchMappingSyncedFiles = (
folderPath: string,
- files: WatchMapping["syncedFiles"],
+ files: FolderWatch["syncedFiles"],
): Promise<void> =>
ipcRenderer.invoke("updateWatchMappingSyncedFiles", folderPath, files);
const updateWatchMappingIgnoredFiles = (
folderPath: string,
- files: WatchMapping["ignoredFiles"],
+ files: FolderWatch["ignoredFiles"],
): Promise<void> =>
ipcRenderer.invoke("updateWatchMappingIgnoredFiles", folderPath, files);
diff --git a/desktop/src/types/ipc.ts b/desktop/src/types/ipc.ts
index 3dba231f20..3dae605a8e 100644
--- a/desktop/src/types/ipc.ts
+++ b/desktop/src/types/ipc.ts
@@ -5,6 +5,20 @@
* See [Note: types.ts <-> preload.ts <-> ipc.ts]
*/
+export interface FolderWatch {
+ rootFolderName: string;
+ uploadStrategy: number;
+ folderPath: string;
+ syncedFiles: FolderWatchSyncedFile[];
+ ignoredFiles: string[];
+}
+
+export interface FolderWatchSyncedFile {
+ path: string;
+ uploadedFileID: number;
+ collectionID: number;
+}
+
/**
* Errors that have special semantics on the web side.
*
@@ -52,22 +66,8 @@ export interface ElectronFile {
arrayBuffer: () => Promise<Uint8Array>;
}
-interface WatchMappingSyncedFile {
- path: string;
- uploadedFileID: number;
- collectionID: number;
-}
-
-export interface WatchMapping {
- rootFolderName: string;
- uploadStrategy: number;
- folderPath: string;
- syncedFiles: WatchMappingSyncedFile[];
- ignoredFiles: string[];
-}
-
export interface WatchStoreType {
- mappings: WatchMapping[];
+ mappings: FolderWatch[];
}
export enum FILE_PATH_TYPE {