mirror of
https://github.com/MercuryWorkshop/adrift.git
synced 2025-05-13 06:10:01 -04:00
disconnect from DB after offers exchange
This commit is contained in:
parent
f50640a642
commit
68aa977962
2 changed files with 6 additions and 2 deletions
|
@ -1,4 +1,4 @@
|
||||||
import { getDatabase, onValue, ref, set, remove } from "firebase/database";
|
import { getDatabase, onValue, ref, set, remove, goOffline } from "firebase/database";
|
||||||
// import "firebase-config";
|
// import "firebase-config";
|
||||||
|
|
||||||
import { v4 as uuid } from "uuid";
|
import { v4 as uuid } from "uuid";
|
||||||
|
@ -53,6 +53,7 @@ export async function signalAccount(offer: string): Promise<Answer> {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
set(peer, offer);
|
set(peer, offer);
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
|
||||||
|
@ -63,6 +64,8 @@ export async function signalAccount(offer: string): Promise<Answer> {
|
||||||
if (data && data.answer && data.candidates) {
|
if (data && data.answer && data.candidates) {
|
||||||
remove(peer);
|
remove(peer);
|
||||||
resolve(data);
|
resolve(data);
|
||||||
|
goOffline(db);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
import logo from "./logo.png";
|
import logo from "./logo.png";
|
||||||
import AccountCreation from "./AccountCreation.svelte";
|
import AccountCreation from "./AccountCreation.svelte";
|
||||||
import { SnackbarIn } from "m3-svelte/package/containers/Snackbar.svelte";
|
import { SnackbarIn } from "m3-svelte/package/containers/Snackbar.svelte";
|
||||||
|
import { goOffline } from "firebase/database";
|
||||||
|
|
||||||
enum ReadyState {
|
enum ReadyState {
|
||||||
Idle,
|
Idle,
|
||||||
|
@ -108,7 +109,7 @@
|
||||||
async function initFirebase() {
|
async function initFirebase() {
|
||||||
if (!chosenTracker) return;
|
if (!chosenTracker) return;
|
||||||
let tracker = TrackerList[chosenTracker];
|
let tracker = TrackerList[chosenTracker];
|
||||||
initializeApp(tracker.firebase);
|
let app = initializeApp(tracker.firebase);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function connectAccount() {
|
async function connectAccount() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue