Skip to content

Commit

Permalink
issue: #1108; precautionary revert;
Browse files Browse the repository at this point in the history
  • Loading branch information
migbash committed May 22, 2023
1 parent ae22849 commit 2aec085
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 21 deletions.
6 changes: 3 additions & 3 deletions src/lib/firebase/common.ts
Expand Up @@ -3,7 +3,7 @@ import { dlog, FIREBASE_DEBUG_STYLE, FIREBASE_DEBUG_TAG, FIREBASE_DEBUG_TOGGLE }
import type { FIRE_LNNS, FIREBASE_livescores_now } from "@betarena/scores-lib/types/firebase.js";
import { onValue, ref, type Unsubscribe } from "firebase/database";
import { getTargetRealDbData } from "./firebase.actions.js";
import { realDb } from "./init";
import { db_real } from "./init";

// #region LIVESCORES_NOW

Expand All @@ -23,7 +23,7 @@ export function listenRealTimeLivescoresNowChange

const dataRef = ref
(
realDb(),
db_real,
'livescores_now/'
);

Expand Down Expand Up @@ -140,7 +140,7 @@ export function listenRealTimeScoreboardAll

const dbRef = ref
(
realDb(),
db_real,
'livescores_now_scoreboard'
);

Expand Down
10 changes: 5 additions & 5 deletions src/lib/firebase/firebase.actions.ts
@@ -1,4 +1,4 @@
import { realDb } from '$lib/firebase/init';
import { db_real } from '$lib/firebase/init';
import { child, get, onValue, ref } from 'firebase/database';

import type { Tournament_Fixture_Odds } from '$lib/models/tournaments/fixtures_odds/types';
Expand Down Expand Up @@ -45,7 +45,7 @@ export async function getOdds_1
(
ref
(
realDb()
db_real
),
`odds/${year_}/${new_month_}/${day_}/${fixture_id}`
)
Expand Down Expand Up @@ -108,7 +108,7 @@ export async function getOdds_2
(
ref
(
realDb()
db_real
),
`odds/${year_}/${new_month_}/${day_}/${fixture_id}`
)
Expand Down Expand Up @@ -151,7 +151,7 @@ export async function getTargetRealDbData

const connectRef = ref
(
realDb()
db_real
);

const snapshot = await get
Expand All @@ -175,7 +175,7 @@ export async function realDbHeartBeat
{
const connectedRef = ref
(
realDb(),
db_real,
".info/connected"
);
onValue
Expand Down
19 changes: 6 additions & 13 deletions src/routes/[[lang=lang]]/+page.svelte
Expand Up @@ -28,8 +28,6 @@
import SvelteSeo from 'svelte-seo';
// TODO:
// -> update to @scores-lib package types;
import { realDbHeartBeat } from '$lib/firebase/firebase.actions.js';
import { firebaseAppDelete, firebaseAppInit } from '$lib/firebase/init.js';
import type { Cache_Single_Homepage_SEO_Translation_Response } from '$lib/models/_main_/pages_and_seo/types';
import type { Cache_Single_Lang_GoalScorers_Translation_Response } from '$lib/models/home/best_goalscorer/types';
import type { Cache_Single_Lang_Featured_Betting_Site_Translation_Response } from '$lib/models/home/featured_betting_sites/firebase-real-db-interface';
Expand Down Expand Up @@ -120,9 +118,14 @@
(
async() =>
{
// NOTE: causes a potential delay in data retrieval,
// as waits for onMount of Page & components;
await onceRealTimeLiveScoreboard()
let connectionRef = listenRealTimeScoreboardAll()
FIREBASE_CONNECTIONS_SET.add(connectionRef)
sportbookIdentify()
document.addEventListener
(
Expand All @@ -131,22 +134,12 @@
(
)
{
if (!document.hidden)
{
console.clear()
if (!document.hidden) {
dlog('🔵 user is active', true)
await firebaseAppInit()
// console.log(getApp())
await realDbHeartBeat()
await onceRealTimeLiveScoreboard()
let connectionRef = listenRealTimeScoreboardAll()
FIREBASE_CONNECTIONS_SET.add(connectionRef)
}
if (document.hidden)
{
dlog('❌ user is inactive', true)
await firebaseAppDelete()
}
}
);
}
Expand Down

0 comments on commit 2aec085

Please sign in to comment.