Revamp of the Settings State System along with TypeScript support (#1560)
* Add vue-rx, rxjs and lodash as dependencies * Added vue-rx plugin integration to nuxt config * Initial settings store implementation * Add babel plugin for private class properties to for Jest * Add DispatchingStore test spec * Initial settings code * Reactive Streams for fb current user and id token * Fix typo * Migrate index and graphql pages to the new store * Migrate network strategy to the new store * Fixed Section.vue errors * Fix getSettingSubject issue * Migrate fb settings reference in components to the new state system * Add typings for lodash as dev dependency * Load setting * Load initial sync setting values * Update proxy url * Add typescript support * Rewrite Settings store to TypeScript * Port Settings page to TypeScript as reference * Move all store migrations to a separate file * Delete test file for fb.js * Add ts-jest as dev dependency * Remove firebase-mock as dependency * Remove FRAME_COLORS_ENABLED settings value
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import firebase from "firebase/app"
|
||||
import "firebase/firestore"
|
||||
import "firebase/auth"
|
||||
import { ReplaySubject } from "rxjs"
|
||||
import { getSettingSubject, applySetting } from "~/newstore/settings"
|
||||
|
||||
// Initialize Firebase, copied from cloud console
|
||||
const firebaseConfig = {
|
||||
@@ -38,6 +40,41 @@ export class FirebaseInstance {
|
||||
this.currentGraphqlCollections = []
|
||||
this.currentEnvironments = []
|
||||
|
||||
this.currentUser$ = new ReplaySubject(1)
|
||||
this.idToken$ = new ReplaySubject(1)
|
||||
|
||||
let loadedSettings = false
|
||||
|
||||
getSettingSubject("syncCollections").subscribe((status) => {
|
||||
if (this.currentUser && loadedSettings) {
|
||||
this.writeSettings("syncCollections", status)
|
||||
}
|
||||
})
|
||||
|
||||
getSettingSubject("syncHistory").subscribe((status) => {
|
||||
if (this.currentUser && loadedSettings) {
|
||||
this.writeSettings("syncHistory", status)
|
||||
}
|
||||
})
|
||||
|
||||
getSettingSubject("syncEnvironments").subscribe((status) => {
|
||||
if (this.currentUser && loadedSettings) {
|
||||
this.writeSettings("syncEnvironments", status)
|
||||
}
|
||||
})
|
||||
|
||||
this.app.auth().onIdTokenChanged((user) => {
|
||||
if (user) {
|
||||
user.getIdToken().then((token) => {
|
||||
this.idToken = token
|
||||
this.idToken$.next(token)
|
||||
})
|
||||
} else {
|
||||
this.idToken = null
|
||||
this.idToken$.next(null)
|
||||
}
|
||||
})
|
||||
|
||||
this.app.auth().onAuthStateChanged((user) => {
|
||||
if (user) {
|
||||
this.currentUser = user
|
||||
@@ -87,6 +124,14 @@ export class FirebaseInstance {
|
||||
settings.push(setting)
|
||||
})
|
||||
this.currentSettings = settings
|
||||
|
||||
settings.forEach((e) => {
|
||||
if (e && e.name && e.value != null) {
|
||||
applySetting(e.name, e.value)
|
||||
}
|
||||
})
|
||||
|
||||
loadedSettings = true
|
||||
})
|
||||
|
||||
this.usersCollection
|
||||
|
||||
Reference in New Issue
Block a user