Changeset 0.28.3 (#187)
This commit is contained in:
@@ -9,8 +9,13 @@
|
||||
// Events.on('chat.message.*', (payload, meta) => { ... });
|
||||
// Events.emit('chat.typing.abc123', { user: 'jeff' });
|
||||
// Events.connect('/ws');
|
||||
//
|
||||
// Exports: window.Events
|
||||
// ==========================================
|
||||
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
const Events = {
|
||||
|
||||
_handlers: new Map(), // label → Set<{fn, once}>
|
||||
@@ -191,9 +196,9 @@ const Events = {
|
||||
}
|
||||
|
||||
// Add auth token as query param (WebSocket doesn't support headers)
|
||||
const tokens = JSON.parse(localStorage.getItem(typeof _storageKey !== 'undefined' ? _storageKey : 'sb_auth') || '{}');
|
||||
if (tokens.accessToken) {
|
||||
url += (url.includes('?') ? '&' : '?') + `token=${encodeURIComponent(tokens.accessToken)}`;
|
||||
const token = (typeof API !== 'undefined' && API.accessToken) ? API.accessToken : null;
|
||||
if (token) {
|
||||
url += (url.includes('?') ? '&' : '?') + `token=${encodeURIComponent(token)}`;
|
||||
} else {
|
||||
console.warn('[EventBus] No auth token — skipping WebSocket');
|
||||
return;
|
||||
@@ -325,3 +330,6 @@ const Events = {
|
||||
return subs;
|
||||
}
|
||||
};
|
||||
|
||||
window.Events = Events;
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user