@@ -29,6 +29,7 @@ import { $t } from 'services/i18n';
29
29
import { debounce } from 'lodash-decorators' ;
30
30
import * as remote from '@electron/remote' ;
31
31
import Utils from '../../../services/utils' ;
32
+ import { NavigationService } from 'app-services' ;
32
33
33
34
@Component ( {
34
35
components : {
@@ -57,6 +58,7 @@ export default class Settings extends Vue {
57
58
@Inject ( ) userService : UserService ;
58
59
@Inject ( ) dismissablesService : DismissablesService ;
59
60
@Inject ( ) dualOutputService : DualOutputService ;
61
+ @Inject ( ) navigationService : NavigationService ;
60
62
61
63
$refs : { settingsContainer : HTMLElement & SearchablePages } ;
62
64
@@ -88,34 +90,38 @@ export default class Settings extends Vue {
88
90
[ 'Appearance' ] : EDismissable . CustomMenuSettings ,
89
91
} ;
90
92
91
- internalCategoryName : string = null ;
92
-
93
93
created ( ) {
94
94
// Make sure we have the latest settings
95
95
this . settingsService . actions . loadSettingsIntoStore ( ) ;
96
96
}
97
97
98
+ currentSettingsTab = 'General' ;
99
+
100
+ unbind : ( ) => void ;
101
+
102
+ mounted ( ) {
103
+ this . unbind = this . navigationService . state . bindProps ( this , {
104
+ currentSettingsTab : 'currentSettingsTab' ,
105
+ } ) ;
106
+ }
107
+
108
+ destroyed ( ) {
109
+ this . unbind ( ) ;
110
+ }
111
+
98
112
/**
99
113
* Whether we have built a cache of searchable pages already.
100
114
* If we havne't - we should debounce the user input.
101
115
* If we have - no need to debounce and we should preserve a snappy experience
102
116
*/
103
117
scanningDone = false ;
104
118
105
- get categoryName ( ) {
106
- if ( this . internalCategoryName == null ) {
107
- this . internalCategoryName = this . getInitialCategoryName ( ) ;
108
- }
109
-
110
- return this . internalCategoryName ;
111
- }
112
-
113
119
get settingsData ( ) {
114
- return this . settingsService . state [ this . categoryName ] ?. formData ?? [ ] ;
120
+ return this . settingsService . state [ this . currentSettingsTab ] ?. formData ?? [ ] ;
115
121
}
116
122
117
- set categoryName ( val : string ) {
118
- this . internalCategoryName = val ;
123
+ setCategoryName ( val : string ) {
124
+ this . navigationService . actions . setSettingsNavigation ( val ) ;
119
125
}
120
126
121
127
get isPrime ( ) {
@@ -153,11 +159,11 @@ export default class Settings extends Vue {
153
159
}
154
160
155
161
get shouldShowReactPage ( ) {
156
- return this . reactPages . includes ( this . categoryName ) ;
162
+ return this . reactPages . includes ( this . currentSettingsTab ) ;
157
163
}
158
164
159
165
get shouldShowVuePage ( ) {
160
- if ( this . reactPages . includes ( this . categoryName ) ) return false ;
166
+ if ( this . reactPages . includes ( this . currentSettingsTab ) ) return false ;
161
167
return ! [
162
168
'Stream' ,
163
169
'API' ,
@@ -169,7 +175,7 @@ export default class Settings extends Vue {
169
175
'Installed Apps' ,
170
176
'Virtual Webcam' ,
171
177
'Developer' ,
172
- ] . includes ( this . categoryName ) ;
178
+ ] . includes ( this . currentSettingsTab ) ;
173
179
}
174
180
175
181
getInitialCategoryName ( ) {
@@ -194,7 +200,7 @@ export default class Settings extends Vue {
194
200
}
195
201
196
202
save ( settingsData : ISettingsSubCategory [ ] ) {
197
- this . settingsService . setSettings ( this . categoryName , settingsData ) ;
203
+ this . settingsService . setSettings ( this . currentSettingsTab , settingsData ) ;
198
204
}
199
205
200
206
done ( ) {
@@ -210,15 +216,15 @@ export default class Settings extends Vue {
210
216
211
217
onBeforePageScanHandler ( page : string ) {
212
218
if ( this . originalCategory == null ) {
213
- this . originalCategory = this . categoryName ;
219
+ this . originalCategory = this . currentSettingsTab ;
214
220
}
215
221
216
- this . categoryName = page ;
222
+ this . setCategoryName ( page ) ;
217
223
}
218
224
219
225
onScanCompletedHandler ( ) {
220
226
this . scanningDone = true ;
221
- this . categoryName = this . originalCategory ;
227
+ this . setCategoryName ( this . originalCategory ) ;
222
228
this . originalCategory = null ;
223
229
}
224
230
@@ -234,8 +240,8 @@ export default class Settings extends Vue {
234
240
this . searchResultPages = foundPages ;
235
241
}
236
242
// if there are not search results for the current page than switch to the first found page
237
- if ( foundPages . length && ! foundPages . includes ( this . categoryName ) ) {
238
- this . categoryName = foundPages [ 0 ] ;
243
+ if ( foundPages . length && ! foundPages . includes ( this . currentSettingsTab ) ) {
244
+ this . setCategoryName ( foundPages [ 0 ] ) ;
239
245
}
240
246
}
241
247
@@ -264,7 +270,7 @@ export default class Settings extends Vue {
264
270
}
265
271
266
272
highlightSearch ( searchStr : string ) {
267
- this . $refs . settingsContainer . highlightPage ( searchStr ) ;
273
+ this . $refs . settingsContainer ? .highlightPage ( searchStr ) ;
268
274
}
269
275
270
276
handleAuth ( ) {
@@ -279,7 +285,7 @@ export default class Settings extends Vue {
279
285
} )
280
286
. then ( ( { response } ) => {
281
287
if ( response === 0 ) {
282
- this . dualOutputService . setDualOutputMode ( false , true ) ;
288
+ this . dualOutputService . setDualOutputModeIfPossible ( false , true ) ;
283
289
this . userService . logOut ( ) ;
284
290
}
285
291
} ) ;
0 commit comments