-
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.
Merge branch 'linux' into merge/linux
- Loading branch information
Showing
24 changed files
with
553 additions
and
73 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
export interface DownloadProgressTracker { | ||
downloadStarted(name: string, extension: string, size: number): Promise<void>; | ||
downloadUpdate( | ||
name: string, | ||
extension: string, | ||
size: number, | ||
progress: { | ||
elapsedTime: number; | ||
percentage: number; | ||
} | ||
): Promise<void>; | ||
downloadFinished( | ||
name: string, | ||
extension: string, | ||
size: number, | ||
progress: { | ||
elapsedTime: number; | ||
} | ||
): Promise<void>; | ||
error(name: string, extension: string): Promise<void>; | ||
} |
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
93 changes: 93 additions & 0 deletions
93
src/context/shared/infrastructure/MainProcessDownloadProgressTracker.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,93 @@ | ||
import { trackError, trackEvent } from '../../../apps/main/analytics/service'; | ||
import { setTrayStatus } from '../../../apps/main/tray/tray'; | ||
import { broadcastToWindows } from '../../../apps/main/windows'; | ||
import { DownloadProgressTracker } from '../domain/DownloadProgressTracker'; | ||
import { SyncMessenger } from '../domain/SyncMessenger'; | ||
|
||
export class MainProcessDownloadProgressTracker | ||
extends SyncMessenger | ||
implements DownloadProgressTracker | ||
{ | ||
async downloadStarted( | ||
name: string, | ||
extension: string, | ||
size: number | ||
): Promise<void> { | ||
setTrayStatus('SYNCING'); | ||
|
||
trackEvent('Upload Started', { | ||
file_name: name, | ||
file_extension: extension, | ||
file_size: size, | ||
elapsedTimeMs: 0, | ||
}); | ||
|
||
broadcastToWindows('sync-info-update', { | ||
action: 'DOWNLOADING', | ||
name: this.nameWithExtension(name, extension), | ||
progress: 0, | ||
}); | ||
} | ||
|
||
async downloadUpdate( | ||
name: string, | ||
extension: string, | ||
size: number, | ||
progress: { elapsedTime: number; percentage: number } | ||
): Promise<void> { | ||
trackEvent('Upload Started', { | ||
file_name: name, | ||
file_extension: extension, | ||
file_size: size, | ||
elapsedTimeMs: progress.elapsedTime, | ||
}); | ||
|
||
broadcastToWindows('sync-info-update', { | ||
action: 'DOWNLOADING', | ||
name: this.nameWithExtension(name, extension), | ||
progress: progress.percentage, | ||
}); | ||
} | ||
|
||
async downloadFinished( | ||
name: string, | ||
extension: string, | ||
size: number, | ||
progress: { | ||
elapsedTime: number; | ||
} | ||
): Promise<void> { | ||
const nameWithExtension = this.nameWithExtension(name, extension); | ||
|
||
setTrayStatus('IDLE'); | ||
|
||
trackEvent('Upload Completed', { | ||
file_name: name, | ||
file_extension: extension, | ||
file_size: size, | ||
elapsedTimeMs: progress.elapsedTime, | ||
}); | ||
|
||
broadcastToWindows('sync-info-update', { | ||
action: 'UPLOADED', | ||
name: nameWithExtension, | ||
}); | ||
} | ||
|
||
async error(name: string, extension: string): Promise<void> { | ||
const nameWithExtension = this.nameWithExtension(name, extension); | ||
|
||
// TODO: finish this | ||
trackError('Upload Error', new Error(), { | ||
itemType: 'File', | ||
root: '', | ||
from: name, | ||
action: 'Upload', | ||
}); | ||
|
||
broadcastToWindows('sync-info-update', { | ||
action: 'DOWNLOAD_ERROR', | ||
name: nameWithExtension, | ||
}); | ||
} | ||
} |
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
30 changes: 30 additions & 0 deletions
30
src/context/virtual-drive/contents/domain/ContentsMetadata.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,30 @@ | ||
import { AggregateRoot } from '../../../shared/domain/AggregateRoot'; | ||
import { DateValueObject } from '../../../shared/domain/value-objects/DateValueObject'; | ||
|
||
type ContentsMetadataAttributes = { | ||
modificationDate: Date; | ||
}; | ||
|
||
export class ContentsMetadata extends AggregateRoot { | ||
private constructor(readonly modificationDate: DateValueObject) { | ||
super(); | ||
} | ||
|
||
static from(attributes: ContentsMetadataAttributes): ContentsMetadata { | ||
return new ContentsMetadata( | ||
new DateValueObject(attributes.modificationDate) | ||
); | ||
} | ||
|
||
attributes(): ContentsMetadataAttributes { | ||
return { | ||
modificationDate: this.modificationDate.value, | ||
}; | ||
} | ||
|
||
isUpToDate(date: Date): boolean { | ||
return ( | ||
this.modificationDate.same(date) || this.modificationDate.isAfter(date) | ||
); | ||
} | ||
} |
Oops, something went wrong.