server and web app
This commit is contained in:
@@ -1,4 +1,23 @@
|
||||
(function () {
|
||||
const realtimeCallbacks = {
|
||||
notification: [],
|
||||
};
|
||||
|
||||
window.__cairnquireRealtime = {
|
||||
on: function (event, cb) {
|
||||
if (realtimeCallbacks[event]) {
|
||||
realtimeCallbacks[event].push(cb);
|
||||
}
|
||||
},
|
||||
off: function (event, cb) {
|
||||
if (realtimeCallbacks[event]) {
|
||||
realtimeCallbacks[event] = realtimeCallbacks[event].filter(function (c) {
|
||||
return c !== cb;
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
const notice = document.querySelector("[data-version-notice]");
|
||||
const reload = document.querySelector("[data-version-reload]");
|
||||
const offlineNotice = document.querySelector("[data-offline-notice]");
|
||||
@@ -300,6 +319,13 @@
|
||||
return;
|
||||
}
|
||||
|
||||
if (payload.type === "notification") {
|
||||
realtimeCallbacks.notification.forEach(function (cb) {
|
||||
cb(payload.data);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (payload.type !== "document_version" || !payload.data) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user