Skip to content

Commit 42d7a20

Browse files
committed
2.3 - Debugging update/set settings
1 parent f093399 commit 42d7a20

File tree

5 files changed

+9
-11
lines changed

5 files changed

+9
-11
lines changed

src/app/app.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ export class AppComponent implements OnInit {
121121
// this.getRelatedVideos();
122122
} else {
123123
this.setDefaultPlayer();
124+
this.shared.getSettings();
124125
}
125-
this.shared.getSettings();
126126
});
127127
}
128128

src/app/components/category/category.component.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ export class CategoryComponent implements OnInit {
2323
) {
2424
// INIT SETTINGS
2525
this.shared.getSettings();
26-
this.shared.setSettings();
2726
}
2827

2928
ngOnInit() {

src/app/components/youtube-settings.component.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ export class SettingsComponent implements OnInit {
6969
this.globals.internal_settings[i].value = data.settings[i];
7070
});
7171
this.globals.settings.form_settings = this.globals.internal_settings;
72-
this.shared.updateSettings();
73-
this.shared.setSettings();
7472

75-
this.app.checkVolumeRange();
73+
this.shared.updateLocalStorageSettings();
74+
this.shared.getSettings();
7675

76+
this.app.checkVolumeRange();
7777
this.shared.triggerNotify('Changed');
7878
});
7979
}
@@ -86,7 +86,6 @@ export class SettingsComponent implements OnInit {
8686
}
8787

8888
getDefaultSettings() {
89-
this.shared.getSettings();
9089
this.globals.internal_settings = this.globals.settings.form_settings;
9190
this.globals.external_settings = this.globals.settings.api_settings;
9291
this.initExternalForm();
@@ -104,9 +103,8 @@ export class SettingsComponent implements OnInit {
104103
this.globals.settings.api_settings = this.globals.external_settings;
105104
this.globals.feedVideos = null;
106105

107-
this.shared.updateSettings();
106+
this.shared.updateLocalStorageSettings();
108107
this.shared.getSettings();
109-
this.shared.setSettings();
110108

111109
this.category.getFeedVideos();
112110

src/app/services/shared.service.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ export class SharedService {
4646
} else {
4747
this.globals.settings = JSON.parse(localStorage.getItem('settings'));
4848
}
49+
this.setSettings();
4950
}
5051

5152
setSettings() {
@@ -62,6 +63,7 @@ export class SharedService {
6263
}
6364

6465
async initFeed() {
66+
await this.getSettings();
6567
const res = await this.youtube.feedVideos();
6668
this.convertVideoObject(res['items'], 'feedVideos');
6769
}
@@ -75,7 +77,7 @@ export class SharedService {
7577
console.log(state);
7678
}
7779

78-
updateSettings() {
80+
updateLocalStorageSettings() {
7981
localStorage.setItem('settings', JSON.stringify(this.globals.settings));
8082
this.setLocalVersion();
8183
}
@@ -91,7 +93,7 @@ export class SharedService {
9193

9294
setLocalVersion() {
9395
if (localStorage.getItem('version') === null) {
94-
localStorage.setItem('version', '2');
96+
localStorage.setItem('version', '1');
9597
}
9698
}
9799

src/app/services/youtube.service.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ export class YoutubeGetVideo {
5454
}
5555

5656
async categories() {
57-
console.log('intra aici');
5857
if (this.globals.apiKey) {
5958
const res = await this.http.get(`${this.url}videoCategories?part=snippet&regionCode=${this.globals.regionCode}&key=${this.globals.apiKey}`)
6059
.map(response => response).toPromise();

0 commit comments

Comments
 (0)