feature: add a map

This commit is contained in:
Andy Burke 2026-01-15 20:53:57 -08:00
parent 19afb7f9fa
commit 32ed2dfd33
23 changed files with 29839 additions and 130 deletions

View file

@ -68,36 +68,10 @@ const APP = {
this._emit( 'view_changed', {
previous,
view
view,
channel_id
});
}
if (!document.body.dataset.channel || document.body.dataset.channel !== channel_id) {
const previous = typeof document.body.dataset.channel === 'string' ? document.body.dataset.channel : undefined;
if ( channel_id ) {
document.body.dataset.channel = channel_id;
}
else {
delete document.body.dataset.channel;
}
const target_channel_id = channel_id ?? this.CHANNELS.CHANNEL_LIST[0]?.id;
// TODO: allow a different default than chat
const hash_target = `/${ view ? view : 'chat' }` + ( target_channel_id ? `/channel/${ target_channel_id }` : '' );
if ( window.location.hash?.slice( 1 ) !== hash_target ) {
if ( previous !== target_channel_id ) {
this._emit( 'channel_changed', {
previous,
channel_id: target_channel_id
});
}
window.location.hash = hash_target;
}
}
},
load: async function() {
@ -236,22 +210,11 @@ const APP = {
const channels_response = await api.fetch("/api/channels");
if (channels_response.ok) {
const new_channels = await channels_response.json();
const has_differences =
APP.CHANNELS.CHANNEL_LIST.length !== new_channels.length ||
new_channels.some((channel, index) => {
return (
APP.CHANNELS.CHANNEL_LIST[index]?.id !== channel.id ||
APP.CHANNELS.CHANNEL_LIST[index]?.name !== channel.name
);
});
APP.CHANNELS.CHANNEL_LIST = [...new_channels];
if (has_differences) {
APP.CHANNELS.CHANNEL_LIST = [...new_channels];
APP._emit( 'channels_updated', {
channels: APP.CHANNELS.CHANNEL_LIST
});
}
APP._emit( 'channels_updated', {
channels: APP.CHANNELS.CHANNEL_LIST
});
APP.CHANNELS._last_channel_update = now;
}