fix: Add postAuthenticate hook for source control preferences (no-changelog) (#6629)

* feat: handle source control settings in post-authenticate app hook

* fix: only trigger post authenticate when logging in

* chore: remove console.log

* chore: fix linting issues

* test: update source control test
This commit is contained in:
Alex Grozav
2023-07-10 12:35:36 +02:00
committed by GitHub
parent 9460bdd3be
commit a95862b6e2
4 changed files with 44 additions and 8 deletions

View File

@@ -92,6 +92,7 @@ export default defineComponent({
},
data() {
return {
postAuthenticateDone: false,
loading: true,
};
},
@@ -215,6 +216,21 @@ export default defineComponent({
} catch {}
}, CLOUD_TRIAL_CHECK_INTERVAL);
},
async postAuthenticate() {
if (this.postAuthenticateDone) {
return;
}
if (!this.usersStore.currentUser) {
return;
}
if (this.sourceControlStore.isEnterpriseSourceControlEnabled) {
await this.sourceControlStore.getPreferences();
}
this.postAuthenticateDone = true;
},
},
async mounted() {
this.setTheme();
@@ -224,10 +240,7 @@ export default defineComponent({
this.redirectIfNecessary();
void this.checkForNewVersions();
void this.checkForCloudPlanData();
if (this.sourceControlStore.isEnterpriseSourceControlEnabled) {
await this.sourceControlStore.getPreferences();
}
void this.postAuthenticate();
this.loading = false;
@@ -239,6 +252,11 @@ export default defineComponent({
}
},
watch: {
'usersStore.currentUser'(currentValue, previousValue) {
if (currentValue && !previousValue) {
void this.postAuthenticate();
}
},
$route(route) {
this.authenticate();
this.redirectIfNecessary();