-
-
Notifications
You must be signed in to change notification settings - Fork 197
/
Copy pathlivesync-process-data-service.ts
40 lines (33 loc) · 1.73 KB
/
livesync-process-data-service.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
export class LiveSyncProcessDataService implements ILiveSyncProcessDataService {
protected processes: IDictionary<ILiveSyncProcessData> = {};
public persistData(projectDir: string, deviceDescriptors: ILiveSyncDeviceDescriptor[], platforms: string[]): void {
this.processes[projectDir] = this.processes[projectDir] || Object.create(null);
this.processes[projectDir].actionsChain = this.processes[projectDir].actionsChain || Promise.resolve();
this.processes[projectDir].currentSyncAction = this.processes[projectDir].actionsChain;
this.processes[projectDir].isStopped = false;
this.processes[projectDir].platforms = platforms;
const currentDeviceDescriptors = this.getDeviceDescriptors(projectDir);
this.processes[projectDir].deviceDescriptors = _.uniqBy(currentDeviceDescriptors.concat(deviceDescriptors), "identifier");
}
public getPersistedData(projectDir: string): ILiveSyncProcessData {
return this.processes[projectDir];
}
public getDeviceDescriptors(projectDir: string): ILiveSyncDeviceDescriptor[] {
const liveSyncProcessesInfo = this.processes[projectDir] || <ILiveSyncProcessData>{};
const currentDescriptors = liveSyncProcessesInfo.deviceDescriptors;
return currentDescriptors || [];
}
public hasDeviceDescriptors(projectDir: string): boolean {
const deviceDescriptors = this.getDeviceDescriptors(projectDir);
return !!deviceDescriptors.length;
}
public getAllPersistedData() {
return this.processes;
}
public getPlatforms(projectDir: string): string[] {
const liveSyncProcessesInfo = this.processes[projectDir] || <ILiveSyncProcessData>{};
const currentPlatforms = liveSyncProcessesInfo.platforms;
return currentPlatforms || [];
}
}
$injector.register("liveSyncProcessDataService", LiveSyncProcessDataService);