Added more database sanity checks

This commit is contained in:
Mitchell McCaffrey
2020-10-23 22:16:18 +11:00
parent 6c8833feae
commit 086a7beff3
5 changed files with 29 additions and 19 deletions
+3 -3
View File
@@ -10,13 +10,13 @@ const TokenDataContext = React.createContext();
const cachedTokenMax = 100;
export function TokenDataProvider({ children }) {
const { database } = useContext(DatabaseContext);
const { database, databaseStatus } = useContext(DatabaseContext);
const { userId } = useContext(AuthContext);
const [tokens, setTokens] = useState([]);
useEffect(() => {
if (!userId || !database) {
if (!userId || !database || databaseStatus === "loading") {
return;
}
function getDefaultTokes() {
@@ -43,7 +43,7 @@ export function TokenDataProvider({ children }) {
}
loadTokens();
}, [userId, database]);
}, [userId, database, databaseStatus]);
async function addToken(token) {
await database.table("tokens").add(token);