From bf21d8391a2ee0deab4877684b64301c92cd0259 Mon Sep 17 00:00:00 2001 From: Abhinav Date: Wed, 15 Jun 2022 14:29:17 +0530 Subject: [PATCH] update watch type --- src/services/watchService.ts | 16 ++++++++-------- src/types/watch/index.ts | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/services/watchService.ts b/src/services/watchService.ts index 225a49d50..7b4d9ed36 100644 --- a/src/services/watchService.ts +++ b/src/services/watchService.ts @@ -6,14 +6,14 @@ import { removeFromCollection, syncCollections } from './collectionService'; import { syncFiles } from './fileService'; import debounce from 'debounce-promise'; import { logError } from 'utils/sentry'; -import { EventQueueType, WatchMapping } from 'types/watch'; +import { EventQueueItem, WatchMapping } from 'types/watch'; import { ElectronAPIsInterface } from 'types/electron'; export class WatchService { ElectronAPIs: ElectronAPIsInterface; allElectronAPIsExist: boolean = false; - eventQueue: EventQueueType[] = []; - currentEvent: EventQueueType; + eventQueue: EventQueueItem[] = []; + currentEvent: EventQueueItem; trashingDirQueue: string[] = []; isEventRunning: boolean = false; uploadRunning: boolean = false; @@ -86,7 +86,7 @@ export class WatchService { }); if (filesToUpload.length > 0) { - const event: EventQueueType = { + const event: EventQueueItem = { type: 'upload', collectionName: mapping.collectionName, files: filesToUpload, @@ -106,7 +106,7 @@ export class WatchService { }); if (filesToRemove.length > 0) { - const event: EventQueueType = { + const event: EventQueueItem = { type: 'trash', collectionName: mapping.collectionName, paths: filesToRemove.map((file) => file.path), @@ -431,7 +431,7 @@ export class WatchService { // Batches all the files to be uploaded (or trashed) from the // event queue of same collection as the next event - private clubSameCollectionEvents(): EventQueueType { + private clubSameCollectionEvents(): EventQueueItem { const event = this.eventQueue.shift(); while ( this.eventQueue.length > 0 && @@ -469,7 +469,7 @@ async function diskFileAddedCallback( console.log('added (upload) to event queue', collectionName, file); - const event: EventQueueType = { + const event: EventQueueItem = { type: 'upload', collectionName, files: [file], @@ -494,7 +494,7 @@ async function diskFileRemovedCallback( return; } - const event: EventQueueType = { + const event: EventQueueItem = { type: 'trash', collectionName, paths: [filePath], diff --git a/src/types/watch/index.ts b/src/types/watch/index.ts index b34594e35..fdd29e4d9 100644 --- a/src/types/watch/index.ts +++ b/src/types/watch/index.ts @@ -9,7 +9,7 @@ export interface WatchMapping { }[]; } -export interface EventQueueType { +export interface EventQueueItem { type: 'upload' | 'trash'; collectionName: string; paths?: string[];