-
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.
feat: create backgorund process messenger
- Loading branch information
1 parent
687914d
commit e936ff6
Showing
15 changed files
with
218 additions
and
41 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
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
12 changes: 8 additions & 4 deletions
12
src/context/virtual-drive/files/domain/SyncFileMessenger.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,11 +1,15 @@ | ||
export interface SyncFileMessenger { | ||
created(name: string, extension: string): Promise<void>; | ||
error(name: string, extension: string, message: string): Promise<void>; | ||
trashing(name: string, type: string, size: number): Promise<void>; | ||
trashed(name: string, type: string, size: number): Promise<void>; | ||
errorWhileCreating( | ||
name: string, | ||
extension: string, | ||
message: string | ||
): Promise<void>; | ||
trashing(name: string, extension: string, size: number): Promise<void>; | ||
trashed(name: string, extension: string, size: number): Promise<void>; | ||
errorWhileTrashing( | ||
name: string, | ||
type: string, | ||
extension: string, | ||
message: string | ||
): Promise<void>; | ||
} |
64 changes: 64 additions & 0 deletions
64
...rtual-drive/files/infrastructure/SyncFileMessengers/BackgroundProcessSyncFileMessenger.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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { SyncEngineIpc } from '../../../../../apps/sync-engine/ipcRendererSyncEngine'; | ||
import { SyncMessenger } from '../../../../shared/domain/SyncMessenger'; | ||
import { SyncFileMessenger } from '../../domain/SyncFileMessenger'; | ||
|
||
export class BackgroundProcessSyncFileMessenger | ||
extends SyncMessenger | ||
implements SyncFileMessenger | ||
{ | ||
constructor(private readonly ipc: SyncEngineIpc) { | ||
super(); | ||
} | ||
|
||
async created(name: string, extension: string): Promise<void> { | ||
this.ipc.send('FILE_CREATED', { | ||
name, | ||
extension, | ||
nameWithExtension: this.nameWithExtension(name, extension), | ||
}); | ||
} | ||
|
||
async errorWhileCreating( | ||
name: string, | ||
extension: string, | ||
message: string | ||
): Promise<void> { | ||
this.ipc.send('FILE_UPLOAD_ERROR', { | ||
name, | ||
extension, | ||
nameWithExtension: this.nameWithExtension(name, extension), | ||
error: message, | ||
}); | ||
} | ||
|
||
async trashing(name: string, extension: string, size: number): Promise<void> { | ||
this.ipc.send('FILE_DELETING', { | ||
name, | ||
extension, | ||
nameWithExtension: this.nameWithExtension(name, extension), | ||
size, | ||
}); | ||
} | ||
|
||
async trashed(name: string, extension: string, size: number): Promise<void> { | ||
this.ipc.send('FILE_DELETED', { | ||
name, | ||
extension, | ||
nameWithExtension: this.nameWithExtension(name, extension), | ||
size, | ||
}); | ||
} | ||
|
||
async errorWhileTrashing( | ||
name: string, | ||
extension: string, | ||
message: string | ||
): Promise<void> { | ||
this.ipc.send('FILE_DELETION_ERROR', { | ||
name, | ||
extension, | ||
nameWithExtension: this.nameWithExtension(name, extension), | ||
error: message, | ||
}); | ||
} | ||
} |
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
16 changes: 11 additions & 5 deletions
16
src/context/virtual-drive/folders/domain/SyncFolderMessenger.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,7 +1,13 @@ | ||
export interface SyncFolderMessenger { | ||
creating(name: string): Promise<void>; | ||
created(name: string): Promise<void>; | ||
rename(name: string, newName: string): Promise<void>; | ||
renamed(name: string, newName: string): Promise<void>; | ||
error(name: string, message: string): Promise<void>; | ||
creating(desiredName: string): Promise<void>; | ||
created(desiredName: string): Promise<void>; | ||
errorWhileCreating(desiredName: string, message: string): Promise<void>; | ||
|
||
rename(currentName: string, desiredName: string): Promise<void>; | ||
renamed(currentName: string, desiredName: string): Promise<void>; | ||
errorWhileRenaming( | ||
currentName: string, | ||
desiredName: string, | ||
message: string | ||
): Promise<void>; | ||
} |
56 changes: 56 additions & 0 deletions
56
...rtual-drive/folders/infrastructure/SyncMessengers/BackgroundProcessSyncFolderMessenger.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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { SyncEngineIpc } from '../../../../../apps/sync-engine/ipcRendererSyncEngine'; | ||
import { SyncMessenger } from '../../../../shared/domain/SyncMessenger'; | ||
import { SyncFolderMessenger } from '../../domain/SyncFolderMessenger'; | ||
|
||
export class BackgroundProcessSyncFolderMessenger | ||
extends SyncMessenger | ||
implements SyncFolderMessenger | ||
{ | ||
constructor(private readonly ipc: SyncEngineIpc) { | ||
super(); | ||
} | ||
|
||
async creating(currentName: string): Promise<void> { | ||
this.ipc.send('FOLDER_CREATING', { name: currentName }); | ||
} | ||
|
||
async created(currentName: string): Promise<void> { | ||
this.ipc.send('FOLDER_CREATED', { name: currentName }); | ||
} | ||
|
||
async errorWhileCreating( | ||
currentName: string, | ||
message: string | ||
): Promise<void> { | ||
this.ipc.send('FOLDER_CREATION_ERROR', { | ||
name: currentName, | ||
error: message, | ||
}); | ||
} | ||
|
||
async rename(currentName: string, desiredName: string): Promise<void> { | ||
this.ipc.send('FOLDER_RENAMING', { | ||
oldName: currentName, | ||
newName: desiredName, | ||
}); | ||
} | ||
|
||
async renamed(currentName: string, desiredName: string): Promise<void> { | ||
this.ipc.send('FOLDER_RENAMED', { | ||
oldName: currentName, | ||
newName: desiredName, | ||
}); | ||
} | ||
|
||
async errorWhileRenaming( | ||
currentName: string, | ||
desiredName: string, | ||
message: string | ||
): Promise<void> { | ||
this.ipc.send('FOLDER_RENAME_ERROR', { | ||
oldName: currentName, | ||
newName: desiredName, | ||
error: message, | ||
}); | ||
} | ||
} |
27 changes: 23 additions & 4 deletions
27
...ructure/MainProcessSyncFolderMessenger.ts → ...sengers/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
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
Oops, something went wrong.