Skip to content

Commit

Permalink
Improve behavior when Firebase isn't configured
Browse files Browse the repository at this point in the history
Provide an empty configuration in the expected place so the build succeeds
Check for an API key in the config and fall back to local storage
  • Loading branch information
nickswalker committed May 17, 2022
1 parent 1d386d9 commit 92cfb14
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/pages/operator/ts/model/firebase.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import {FirebaseOptions} from "firebase/app";

// Provide a configuration if you'd like to use Firebase.
// Don't commit your secrets!
export const CONFIG: FirebaseOptions = {
}
7 changes: 6 additions & 1 deletion src/pages/operator/ts/model/firebasemodel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class FirebaseModel extends Model {
private localSettings?: Settings
private sessions: string[] = [];

constructor(config = CONFIG, readyCallback = (model: FirebaseModel) => { }) {
constructor(config: FirebaseOptions = CONFIG, readyCallback = (model: FirebaseModel) => { }) {
super();
this.isAnonymous = false;
this.uid = "";
Expand Down Expand Up @@ -343,4 +343,9 @@ export class FirebaseModel extends Model {
updates['/users/' + (this.uid) + '/settings'] = settings;
return update(ref(this.database), updates);
}

static isConfigurationValid(config: FirebaseOptions) {
// Do we atleast have a key configured?
return config.apiKey != undefined
}
}

0 comments on commit 92cfb14

Please sign in to comment.