frontend: add useAuthHandlers in main.js

This commit is contained in:
hippoz 2022-05-05 20:39:24 +03:00
parent d0a61450c5
commit 243036f29e
Signed by: hippoz
GPG key ID: 7C52899193467641
2 changed files with 3 additions and 4 deletions

View file

@ -2,7 +2,7 @@ import gateway, { GatewayEventType } from "./gateway";
import { removeItem, setItem } from "./storage"; import { removeItem, setItem } from "./storage";
import { overlayStore } from "./stores"; import { overlayStore } from "./stores";
function useAuthHandlers() { export function useAuthHandlers() {
gateway.subscribe(GatewayEventType.Ready, () => { gateway.subscribe(GatewayEventType.Ready, () => {
overlayStore.close("login"); overlayStore.close("login");
overlayStore.close("createAccount"); overlayStore.close("createAccount");
@ -24,5 +24,3 @@ export function logOut() {
gateway.close(); gateway.close();
gateway.dispatch(GatewayEventType.BadAuth, -1); gateway.dispatch(GatewayEventType.BadAuth, -1);
} }
useAuthHandlers();

View file

@ -2,7 +2,7 @@ import Main from './components/Main.svelte';
import gateway from './gateway'; import gateway from './gateway';
import { getItem, init } from './storage'; import { getItem, init } from './storage';
import logging from "./logging"; import logging from "./logging";
import { authWithToken } from './auth'; import { authWithToken, useAuthHandlers } from './auth';
import { initResponsiveHandlers } from './responsive'; import { initResponsiveHandlers } from './responsive';
window.__waffle = { window.__waffle = {
@ -12,6 +12,7 @@ window.__waffle = {
init(); init();
initResponsiveHandlers(); initResponsiveHandlers();
useAuthHandlers();
authWithToken(getItem("token")); authWithToken(getItem("token"));
// Remove loading screen // Remove loading screen