From 647bc01098d5cb70aa791cfe9dd46d40e324d704 Mon Sep 17 00:00:00 2001 From: Kai Date: Tue, 23 Jan 2024 11:57:32 -0500 Subject: [PATCH] make leaderboard visible --- src/chat_socket.ts | 2 +- src/components/App.vue | 2 +- src/main.ts | 8 +++++++- src/store.ts | 4 ++-- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/chat_socket.ts b/src/chat_socket.ts index ccae741..17b57c5 100644 --- a/src/chat_socket.ts +++ b/src/chat_socket.ts @@ -7,7 +7,7 @@ declare const CONFIG: Config|undefined; let ws: ReconnectingWebSocket|null = null; export function connectChatSocket() { - if (!CONFIG) return null; + if (!CONFIG) return; ws = new ReconnectingWebSocket(CONFIG.chat_url); } diff --git a/src/components/App.vue b/src/components/App.vue index a58bcdb..db8ab65 100644 --- a/src/components/App.vue +++ b/src/components/App.vue @@ -7,7 +7,7 @@ import Leaderboard from "components/Leaderboard.vue";
-
+
diff --git a/src/main.ts b/src/main.ts index 1294147..fb85afe 100644 --- a/src/main.ts +++ b/src/main.ts @@ -4,7 +4,8 @@ import {createPinia} from 'pinia'; import 'neuroglancer/ui/default_viewer.css'; import App from 'components/App.vue'; -import {useLayersStore} from 'src/store'; +import {useLayersStore, useStatsStore, useChatStore} from 'src/store'; +import {connectChatSocket} from 'src/chat_socket'; import {setupDefaultViewer} from 'third_party/neuroglancer/ui/default_viewer_setup'; function mergeTopBars() { @@ -25,4 +26,9 @@ window.addEventListener('DOMContentLoaded', () => { const viewer = setupDefaultViewer(); initializeWithViewer(viewer); mergeTopBars(); + const {loopUpdateLeaderboard} = useStatsStore(); + loopUpdateLeaderboard(); + connectChatSocket(); + const {joinChat} = useChatStore(); + joinChat(); }); diff --git a/src/store.ts b/src/store.ts index 678c42a..0f8b02e 100644 --- a/src/store.ts +++ b/src/store.ts @@ -278,7 +278,7 @@ export const useStatsStore = defineStore('stats', () => { */ } - return {leaderboardLoaded, leaderboardEntries, setLeaderboardTimespan, resetLeaderboard}; + return {leaderboardLoaded, leaderboardEntries, setLeaderboardTimespan, resetLeaderboard, loopUpdateLeaderboard}; }); interface ServerMessage { @@ -439,5 +439,5 @@ export const useChatStore = defineStore('chat', () => { } } - return {chatMessages, unreadMessages, sendMessage, markLastMessageRead}; + return {chatMessages, unreadMessages, sendMessage, markLastMessageRead, joinChat}; });