@@ -6,6 +6,7 @@ import { DbStatusService } from './db-status.service';
6
6
import { ProgressService } from './progress.service' ;
7
7
import { DbCompletionService } from './db-completion.service' ;
8
8
import { StType } from '../type' ;
9
+ import { DeviceService } from './device.service' ;
9
10
10
11
@Injectable ( {
11
12
providedIn : 'root'
@@ -19,6 +20,7 @@ export class FolderService {
19
20
20
21
constructor (
21
22
private systemConfigService : SystemConfigService ,
23
+ private deviceService : DeviceService ,
22
24
private dbStatusService : DbStatusService ,
23
25
private dbCompletionService : DbCompletionService ,
24
26
private progressService : ProgressService ,
@@ -33,24 +35,48 @@ export class FolderService {
33
35
}
34
36
const folder : Folder = this . folders [ startIndex ] ;
35
37
startIndex = startIndex + 1 ;
36
- this . dbStatusService . getFolderStatus ( folder . id ) . subscribe (
37
- status => {
38
- folder . status = status ;
39
38
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 ;
45
50
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
+ }
51
53
} ) ;
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
+ ) ;
52
77
}
53
- ) ;
78
+ )
79
+
54
80
}
55
81
56
82
/**
0 commit comments