Skip to content
This repository was archived by the owner on Feb 10, 2021. It is now read-only.

Commit 8b4a1f5

Browse files
committed
update folder devices array for the "shared with" section in the folder list #CTR-2
1 parent 7a9f317 commit 8b4a1f5

File tree

1 file changed

+40
-14
lines changed

1 file changed

+40
-14
lines changed

src/app/services/folder.service.ts

Lines changed: 40 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { DbStatusService } from './db-status.service';
66
import { ProgressService } from './progress.service';
77
import { DbCompletionService } from './db-completion.service';
88
import { StType } from '../type';
9+
import { DeviceService } from './device.service';
910

1011
@Injectable({
1112
providedIn: 'root'
@@ -19,6 +20,7 @@ export class FolderService {
1920

2021
constructor(
2122
private systemConfigService: SystemConfigService,
23+
private deviceService: DeviceService,
2224
private dbStatusService: DbStatusService,
2325
private dbCompletionService: DbCompletionService,
2426
private progressService: ProgressService,
@@ -33,24 +35,48 @@ export class FolderService {
3335
}
3436
const folder: Folder = this.folders[startIndex];
3537
startIndex = startIndex + 1;
36-
this.dbStatusService.getFolderStatus(folder.id).subscribe(
37-
status => {
38-
folder.status = status;
3938

40-
this.dbCompletionService.getCompletion(StType.Folder, folder.id).subscribe(
41-
c => {
42-
folder.completion = c;
43-
folder.stateType = Folder.getStateType(folder);
44-
folder.state = Folder.stateTypeToString(folder.stateType);
39+
// Folder devices array only has deviceID
40+
// and we want all the device info
41+
this.systemConfigService.getDevices().subscribe(
42+
devices => {
43+
devices.forEach(device => {
44+
// Update any device this folder
45+
// has reference to
46+
folder.devices.forEach((folderDevice, index) => {
47+
if (folderDevice.deviceID === device.deviceID) {
48+
console.log("find device match?", device.name)
49+
folder.devices[index] = device;
4550

46-
this.folderAddedSource.next(folder);
47-
this.progressService.addToProgress(1);
48-
49-
// recursively get the status of the next folder
50-
this.getFolderStatusInOrder(startIndex);
51+
console.log("update?", folder.devices);
52+
}
5153
});
54+
});
55+
56+
// Gather the folder information from the status and
57+
// completion services
58+
this.dbStatusService.getFolderStatus(folder.id).subscribe(
59+
status => {
60+
folder.status = status;
61+
62+
this.dbCompletionService.getCompletion(StType.Folder, folder.id).subscribe(
63+
c => {
64+
folder.completion = c;
65+
folder.stateType = Folder.getStateType(folder);
66+
folder.state = Folder.stateTypeToString(folder.stateType);
67+
68+
this.folderAddedSource.next(folder);
69+
this.progressService.addToProgress(1);
70+
71+
// Now that we have all the folder information
72+
// recursively get the status of the next folder
73+
this.getFolderStatusInOrder(startIndex);
74+
});
75+
}
76+
);
5277
}
53-
);
78+
)
79+
5480
}
5581

5682
/**

0 commit comments

Comments
 (0)