fixing updating of status so that we get it done on unload
This commit is contained in:
@@ -54,7 +54,7 @@ export default function AudioContextProvider({ children }) {
|
||||
const [isRecording, setIsRecording] = useState<Boolean>(false);
|
||||
const [hasRecPermit, setHasRecPermit] = useState<Boolean>(false);
|
||||
|
||||
const [teamShortcutMappings, setTeamShortcutMappings] = useState<{}>(null);
|
||||
const [teamShortcutMappings, setTeamShortcutMappings] = useState<{}>({});
|
||||
const [audioInputDeviceId, setAudioInputDevice] = useState<string>(null); // device id
|
||||
const [audioOutputDeviceId, setAudioOutputDevice] = useState<string>(null); // device id
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
User,
|
||||
} from "firebase/auth";
|
||||
import React, { useContext, useEffect, useState } from "react";
|
||||
import toast from "react-hot-toast";
|
||||
import firebase from "../services/firebaseService";
|
||||
|
||||
const AuthContext = React.createContext(null);
|
||||
@@ -44,6 +45,7 @@ export function AuthProvider({ children }) {
|
||||
.then((res) => {
|
||||
// This gives you a Google Access Token. You can use it to access the Google API.
|
||||
const credential = GoogleAuthProvider.credentialFromResult(res);
|
||||
|
||||
const token = credential.accessToken;
|
||||
// The signed-in user info.
|
||||
const user = res.user;
|
||||
@@ -61,7 +63,7 @@ export function AuthProvider({ children }) {
|
||||
// The AuthCredential type that was used.
|
||||
const credential = GoogleAuthProvider.credentialFromError(error);
|
||||
console.log(error);
|
||||
throw error;
|
||||
toast.error("something went wrong");
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -66,9 +66,9 @@ export default class UserService {
|
||||
);
|
||||
}
|
||||
|
||||
async updateUserStatus(userId: string, newStatus: UserStatus) {
|
||||
updateUserStatus(userId: string, newStatus: UserStatus) {
|
||||
const docRef = doc(this.db, Collections.users, userId);
|
||||
await setDoc(
|
||||
setDoc(
|
||||
docRef,
|
||||
{ userStatus: newStatus, lastUpdatedDate: serverTimestamp() },
|
||||
{ merge: true }
|
||||
|
||||
Reference in New Issue
Block a user