mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-16 04:43:35 +00:00
refactor: WS (#1622)
* refactor: WS * refactor refetch extract refetch keys to package/types auto invalidata all keys use refetch keys for project data no need for constant update of info, just fetch when looking at it split refetch and query keys rename types * refactor viewSettings * fixup! refactor: WS * rearange files and make types for api calls * cleanup viewsettings * switch exhaustiveCheck * combine send socket function * exhaustive check * rename type to tag * fixup! fixup! refactor: WS * remove custom etag solution * get errors from socket * lint * small change --------- Co-authored-by: Carlos Valente <carlosvalente@pm.me>
This commit is contained in:
committed by
GitHub
parent
c8fe0bbcba
commit
31d47ed1e5
@@ -1,4 +1,4 @@
|
||||
import { RuntimeStore } from 'ontime-types';
|
||||
import { RuntimeStore, MessageTag } from 'ontime-types';
|
||||
|
||||
import { socket } from '../adapters/WebsocketAdapter.js';
|
||||
import { isEmptyObject } from '../utils/parserUtils.js';
|
||||
@@ -23,7 +23,7 @@ export const eventStore = {
|
||||
},
|
||||
set<T extends keyof RuntimeStore>(key: T, value: RuntimeStore[T]) {
|
||||
store[key] = value;
|
||||
socket.sendAsJson({ type: 'ontime-patch', payload: { [key]: value } });
|
||||
socket.sendAsJson(MessageTag.RuntimePatch, { [key]: value });
|
||||
},
|
||||
createBatch() {
|
||||
const patch: Partial<RuntimeStore> = {};
|
||||
@@ -34,7 +34,7 @@ export const eventStore = {
|
||||
send() {
|
||||
if (isEmptyObject(patch)) return;
|
||||
store = { ...store, ...patch };
|
||||
socket.sendAsJson({ type: 'ontime-patch', payload: patch });
|
||||
socket.sendAsJson(MessageTag.RuntimePatch, patch);
|
||||
},
|
||||
};
|
||||
},
|
||||
@@ -42,9 +42,9 @@ export const eventStore = {
|
||||
return store as RuntimeStore;
|
||||
},
|
||||
broadcast() {
|
||||
socket.sendAsJson({
|
||||
type: 'ontime',
|
||||
payload: store,
|
||||
});
|
||||
socket.sendAsJson(
|
||||
MessageTag.RuntimeData,
|
||||
store as RuntimeStore, // We assume that it has been initialized at this point
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user