update
This commit is contained in:
parent
0358a6025b
commit
deaf58dfce
7 changed files with 19 additions and 17 deletions
12
frontend/src/@types/dom.d.ts
vendored
Normal file
12
frontend/src/@types/dom.d.ts
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
interface CustomEventMap {
|
||||
"ft:pageChange": CustomEvent<{}>;
|
||||
}
|
||||
|
||||
declare global {
|
||||
interface Document { //adds definition to Document, but you can do the same with HTMLElement
|
||||
addEventListener<K extends keyof CustomEventMap>(type: K,
|
||||
listener: (this: Document, ev: CustomEventMap[K]) => void): void;
|
||||
dispatchEvent<K extends keyof CustomEventMap>(ev: CustomEventMap[K]): void;
|
||||
}
|
||||
}
|
||||
export { }; //keep that for TS compiler.
|
||||
|
|
@ -6,6 +6,12 @@ import { getUser, updateUser } from "@app/auth";
|
|||
import io, { Socket } from 'socket.io-client';
|
||||
|
||||
let __socket: Socket | undefined = undefined;
|
||||
document.addEventListener('ft:pageChange', () => {
|
||||
if (__socket !== undefined)
|
||||
__socket.close();
|
||||
__socket = undefined;
|
||||
console.log("Page changed");
|
||||
})
|
||||
function getSocket(): Socket {
|
||||
if (__socket === undefined)
|
||||
__socket = io("wss://localhost:8888", {
|
||||
|
|
|
|||
|
|
@ -195,6 +195,7 @@ export async function handleRoute() {
|
|||
if (user === null && !route_handler.special_args.bypass_auth)
|
||||
return navigateTo(`/login?returnTo=${encodeURIComponent(window.location.pathname)}`)
|
||||
const app = document.getElementById('app')!;
|
||||
document.dispatchEvent(new CustomEvent('ft:pageChange' as any, {} as any) as any);
|
||||
let ret = await executeRouteHandler(route_handler, window.location.pathname, args)
|
||||
app.innerHTML = ret.html;
|
||||
if (ret.postInsert) {
|
||||
|
|
|
|||
|
|
@ -4,15 +4,5 @@ set -e
|
|||
set -x
|
||||
# do anything here
|
||||
|
||||
mkdir -p /volumes/static/chat/
|
||||
|
||||
cp -r /extra/chat.html /volumes/static/chat/chat.html
|
||||
|
||||
cp -r /extra/chat.js /volumes/static/chat/chat.js
|
||||
cp -r /extra/style.css /volumes/static/chat/style.css
|
||||
|
||||
|
||||
# chmod -R a+r /volumes/static/chat || true
|
||||
|
||||
# run the CMD [ ... ] from the dockerfile
|
||||
exec "$@"
|
||||
|
|
|
|||
|
|
@ -1,4 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!-- OLD HTML to be deleted later -->
|
||||
</html>
|
||||
|
|
@ -1 +0,0 @@
|
|||
// OLD JS file to be deleted later
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
/*! tailwindcss v4.1.16 | MIT License | https://tailwindcss.com */
|
||||
/* Old css to be deleted later */
|
||||
Loading…
Add table
Add a link
Reference in a new issue