Compare commits

..

No commits in common. "144877e6821738970b3954279cc271822992e3a1" and "b93b610eef66a3470d0be9a1df7a47ead4e5bbec" have entirely different histories.

7 changed files with 35 additions and 25 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";
export function useAuthHandlers() { function useAuthHandlers() {
gateway.subscribe(GatewayEventType.Ready, () => { gateway.subscribe(GatewayEventType.Ready, () => {
overlayStore.close("login"); overlayStore.close("login");
overlayStore.close("createAccount"); overlayStore.close("createAccount");
@ -24,3 +24,5 @@ export function logOut() {
gateway.close(); gateway.close();
gateway.dispatch(GatewayEventType.BadAuth, -1); gateway.dispatch(GatewayEventType.BadAuth, -1);
} }
useAuthHandlers();

View file

@ -1,7 +1,8 @@
<script> <script>
import { HashIcon, PlusIcon, MoreVerticalIcon, SettingsIcon } from "svelte-feather-icons"; import { HashIcon, PlusIcon, MoreVerticalIcon, SettingsIcon } from "svelte-feather-icons";
import { quadInOut } from "svelte/easing"; import { quadInOut } from "svelte/easing";
import { maybeFly } from "../animations"; import { fly } from "svelte/transition";
import { maybeFade } from "../animations";
import { channels, overlayStore, selectedChannel, showChannelView, showSidebar, smallViewport, userInfoStore } from "../stores"; import { channels, overlayStore, selectedChannel, showChannelView, showSidebar, smallViewport, userInfoStore } from "../stores";
import UserTopBar from "./UserTopBar.svelte"; import UserTopBar from "./UserTopBar.svelte";
@ -30,7 +31,7 @@
}; };
</script> </script>
<div class="sidebar-container" transition:maybeFly="{{ duration: 200, easing: quadInOut, x: -10 }}" on:outroend="{ outroEnd }"> <div class="sidebar-container" transition:maybeFade="{{ duration: 200, easing: quadInOut, x: -10 }}" on:outroend="{ outroEnd }">
<UserTopBar /> <UserTopBar />
<div class="sidebar"> <div class="sidebar">
{#each $channels as channel (channel.id)} {#each $channels as channel (channel.id)}

View file

@ -1,4 +1,4 @@
import logger from "./logging"; import logging from "./logging";
import { getItem } from "./storage"; import { getItem } from "./storage";
export const GatewayErrors = { export const GatewayErrors = {
@ -35,7 +35,7 @@ export const GatewayEventType = {
BadAuth: -3, BadAuth: -3,
} }
const log = logger("Gateway"); const log = logging.logger("Gateway", true);
export default { export default {
ws: null, ws: null,

View file

@ -1,8 +1,9 @@
import { getItem } from "./storage"; export default {
sinks: new Map(),
export default function logger(sink) { logger(sink, enabled=false) {
this.sinks.set(sink, enabled);
return (...args) => { return (...args) => {
if (getItem(`loggingSink:${sink}`)) { if (this.sinks.get(sink)) {
console.log( console.log(
`%c[${sink}]`, `%c[${sink}]`,
"color: #8f3f71; font-weight: bold;", "color: #8f3f71; font-weight: bold;",
@ -10,4 +11,11 @@ export default function logger(sink) {
); );
} }
}; };
},
enableSink(sink) {
this.sinks.set(sink, true);
},
disableSink(sink) {
this.sinks.set(sink, false);
} }
};

View file

@ -1,16 +1,17 @@
import Main from './components/Main.svelte'; 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 { authWithToken, useAuthHandlers } from './auth'; import logging from "./logging";
import { authWithToken } from './auth';
import { initResponsiveHandlers } from './responsive'; import { initResponsiveHandlers } from './responsive';
window.__waffle = { window.__waffle = {
logging,
gateway gateway
}; };
init(); init();
initResponsiveHandlers(); initResponsiveHandlers();
useAuthHandlers();
authWithToken(getItem("token")); authWithToken(getItem("token"));
// Remove loading screen // Remove loading screen

View file

@ -2,9 +2,7 @@ const defaults = {
apiBase: `${window.location.origin}/api/v1`, apiBase: `${window.location.origin}/api/v1`,
gatewayBase: `${location.protocol === "https:" ? "wss" : "ws"}://${location.host}/gateway`, gatewayBase: `${location.protocol === "https:" ? "wss" : "ws"}://${location.host}/gateway`,
doAnimations: true, doAnimations: true,
token: "", token: ""
"loggingSink:Gateway": false,
"loggingSink:Store": false
}; };
const store = new Map(Object.entries(defaults)); const store = new Map(Object.entries(defaults));
const persistentProvider = localStorage; const persistentProvider = localStorage;

View file

@ -1,9 +1,9 @@
import gateway, { GatewayEventType } from "./gateway"; import gateway, { GatewayEventType } from "./gateway";
import logger from "./logging"; import logging from "./logging";
import request from "./request"; import request from "./request";
import { apiRoute } from "./storage"; import { apiRoute } from "./storage";
const storeLog = logger("Store"); const storeLog = logging.logger("Store", true);
class Store { class Store {
constructor(value=null, name="[unnamed]") { constructor(value=null, name="[unnamed]") {