Skip to content

Commit

Permalink
Fix firebase db access.
Browse files Browse the repository at this point in the history
  • Loading branch information
s-dimaria committed Feb 3, 2024
1 parent 5cd25c1 commit 6642a68
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
10 changes: 5 additions & 5 deletions src/components/utils/dataService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { getDayStr, getDayStrAsPath } from ".";
import { SongConfig } from "../game/SongConfig";
import { artists } from "../utils/artists";
import { getDatabase, ref, onValue, set } from "firebase/database";
import "./firebase";
import { db } from "./firebase";
import { banWords } from "../game/Constants";

interface Map {
Expand All @@ -25,11 +25,11 @@ const DEFAULT_SONG = {
const SONG_DATABASE: Map = {};

const setSong = (day: string, selectedSong: any) => {
const database = getDatabase();
//const database = getDatabase();

let hardCodedSong = selectedSong;

set(ref(database, "songs/" + day), hardCodedSong);
set(ref(db, "songs/" + day), hardCodedSong);
};

async function fetchSong(accessToken: string, artist: string): Promise<any> {
Expand Down Expand Up @@ -70,7 +70,7 @@ export const getDailySong = (

return new Promise<SongConfig>(async (resolve, reject) => {

const database = getDatabase();
//const database = getDatabase();

let selectedSong: any;
var value: boolean = true;
Expand Down Expand Up @@ -129,7 +129,7 @@ export const getDailySong = (
image: selectedSong.album.images[0].url,
};

const songRef = ref(database, "songs/" + dayPath);
const songRef = ref(db, "songs/" + dayPath);

onValue(
songRef,
Expand Down
3 changes: 3 additions & 0 deletions src/components/utils/firebase.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { initializeApp} from 'firebase/app';
import { getAnalytics } from "firebase/analytics";
import { getDatabase } from 'firebase/database';

const firebaseConfig = {
apiKey: process.env.REACT_APP_FIREBASE_API_KEY,
Expand All @@ -14,4 +15,6 @@ const firebaseConfig = {

// Initialize Firebase
const app = initializeApp(firebaseConfig);

export const db = getDatabase(app);
const analytics = getAnalytics(app);
4 changes: 1 addition & 3 deletions src/components/utils/firebaseRealtime.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { getDatabase, ref, set, get, update, remove } from "firebase/database";
import { uid } from "uid";
import "./firebase";

const db = getDatabase();
import { db } from "./firebase";

function getDB() {
return db;
Expand Down

0 comments on commit 6642a68

Please sign in to comment.