-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ab3816e
commit 7785431
Showing
6 changed files
with
78 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,36 @@ | ||
type DriveOperationInProgress = { | ||
action: 'UPLOADING' | 'DOWNLOADING' | 'RENAMING' | 'DELETING'; | ||
const actionsInProgress = ['UPLOADING', 'DOWNLOADING'] as const; | ||
|
||
type ActionWithProgress = (typeof actionsInProgress)[number]; | ||
|
||
type DriveOperationWithProgress = { | ||
action: ActionWithProgress; | ||
progress: number; | ||
oldName: string; | ||
name: string; | ||
}; | ||
type DriveOperationCompleted = { | ||
action: 'UPLOADED' | 'DOWNLOADED' | 'RENAMED' | 'DELETED'; | ||
|
||
const actions = [ | ||
'RENAMING', | ||
'DELETING', | ||
'UPLOADED', | ||
'DOWNLOADED', | ||
'RENAMED', | ||
'DELETED', | ||
'RENAMING_FOLDER', | ||
'CREATING_FOLDER', | ||
'FOLDER_RENAMED', | ||
'FOLDER_CREATED', | ||
] as const; | ||
|
||
type Action = (typeof actions)[number]; | ||
|
||
type DriveOperation = { | ||
action: Action; | ||
name: string; | ||
oldName: string | undefined; | ||
progress: undefined; // Needed so ts does not complain with the union type | ||
}; | ||
|
||
export type DriveInfo = DriveOperationInProgress | DriveOperationCompleted; | ||
export type DriveOperationInfo = DriveOperationWithProgress | DriveOperation; | ||
|
||
export type DriveAction = Action | ActionWithProgress; |
41 changes: 35 additions & 6 deletions
41
...ext/virtual-drive/folders/infrastructure/SyncMessengers/MainProcessSyncFolderMessenger.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,60 @@ | ||
import { trackVirtualDriveError } from '../../../../../apps/main/analytics/service'; | ||
import { addVirtualDriveIssue } from '../../../../../apps/main/issues/virtual-drive'; | ||
import { setTrayStatus } from '../../../../../apps/main/tray/tray'; | ||
import { notifyIssueToUser } from '../../../../../apps/main/windows'; | ||
import { virtualDriveUpdate } from '../../../../../apps/main/windows'; | ||
import { VirtualDriveFolderIssue } from '../../../../../shared/issues/VirtualDriveIssue'; | ||
import { SyncFolderMessenger } from '../../domain/SyncFolderMessenger'; | ||
|
||
export class MainProcessSyncFolderMessenger implements SyncFolderMessenger { | ||
async rename(_name: string, _newName: string): Promise<void> { | ||
async rename(name: string, newName: string): Promise<void> { | ||
setTrayStatus('SYNCING'); | ||
|
||
virtualDriveUpdate({ | ||
action: 'RENAMING_FOLDER', | ||
oldName: name, | ||
name: newName, | ||
progress: undefined, | ||
}); | ||
} | ||
|
||
async renamed(_name: string, _newName: string): Promise<void> { | ||
async renamed(name: string, newName: string): Promise<void> { | ||
setTrayStatus('IDLE'); | ||
|
||
virtualDriveUpdate({ | ||
action: 'FOLDER_RENAMED', | ||
oldName: name, | ||
name: newName, | ||
progress: undefined, | ||
}); | ||
} | ||
|
||
async creating(_name: string): Promise<void> { | ||
async creating(name: string): Promise<void> { | ||
setTrayStatus('SYNCING'); | ||
|
||
virtualDriveUpdate({ | ||
action: 'CREATING_FOLDER', | ||
oldName: undefined, | ||
name: name, | ||
progress: undefined, | ||
}); | ||
} | ||
|
||
async created(_name: string): Promise<void> { | ||
async created(name: string): Promise<void> { | ||
setTrayStatus('IDLE'); | ||
|
||
virtualDriveUpdate({ | ||
action: 'FOLDER_CREATED', | ||
oldName: undefined, | ||
name: name, | ||
progress: undefined, | ||
}); | ||
} | ||
|
||
async error(issue: VirtualDriveFolderIssue): Promise<void> { | ||
setTrayStatus('ALERT'); | ||
|
||
trackVirtualDriveError(issue); | ||
|
||
notifyIssueToUser(issue); | ||
addVirtualDriveIssue(issue); | ||
} | ||
} |