fix: more navigation and chat fixes

This commit is contained in:
Andy Burke 2025-11-09 13:16:49 -08:00
parent de77f0fbe9
commit 0bc303a762
2 changed files with 16 additions and 47 deletions

View file

@ -161,7 +161,7 @@ export async function POST(req: Request, meta: Record<string, any>): Promise<Res
await INVITE_CODES.create(root_invite_code); await INVITE_CODES.create(root_invite_code);
} }
const secret_code = submitted_invite_code ?? root_invite_code_secret; const secret_code = root_invite_code_secret ?? submitted_invite_code; // if it's the first user, use the autogen code, ignore anything they submit
if (typeof secret_code !== 'string' || secret_code.length < 3) { if (typeof secret_code !== 'string' || secret_code.length < 3) {
return Response.json({ return Response.json({
error: { error: {

View file

@ -57,29 +57,24 @@ const APP = {
groups: {}, groups: {},
}; };
/* if (!document.body.dataset.view || document.body.dataset.view !== view) {
console.dir({ const previous = typeof document.body.dataset.view === 'string' ? document.body.dataset.view : undefined;
url: window.location.href, if ( view ) {
hash: window.location.hash, document.body.dataset.view = view;
view, }
channel_id, else {
delete document.body.dataset.view;
}
this._emit( 'view_changed', {
previous,
view
}); });
*/ }
if (!document.body.dataset.channel || document.body.dataset.channel !== 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; const previous = typeof document.body.dataset.channel === 'string' ? document.body.dataset.channel : undefined;
/*
console.dir({
channel_changed: {
detail: {
previous,
channel_id,
},
},
});
*/
if ( channel_id ) { if ( channel_id ) {
document.body.dataset.channel = channel_id; document.body.dataset.channel = channel_id;
} }
@ -90,7 +85,7 @@ const APP = {
const target_channel_id = channel_id ?? this.CHANNELS.CHANNEL_LIST[0]?.id; const target_channel_id = channel_id ?? this.CHANNELS.CHANNEL_LIST[0]?.id;
// TODO: allow a different default than chat // TODO: allow a different default than chat
const hash_target = '/chat' + ( target_channel_id ? `/channel/${ target_channel_id }` : '' ); const hash_target = `/${ view ? view : 'chat' }` + ( target_channel_id ? `/channel/${ target_channel_id }` : '' );
if ( window.location.hash?.slice( 1 ) !== hash_target ) { if ( window.location.hash?.slice( 1 ) !== hash_target ) {
if ( previous !== target_channel_id ) { if ( previous !== target_channel_id ) {
@ -103,32 +98,6 @@ const APP = {
window.location.hash = hash_target; window.location.hash = hash_target;
} }
} }
if (!document.body.dataset.view || document.body.dataset.view !== view) {
const previous = typeof document.body.dataset.view === 'string' ? document.body.dataset.view : undefined;
if ( view ) {
document.body.dataset.view = view;
}
else {
delete document.body.dataset.view;
}
/*
console.dir({
view_changed: {
detail: {
previous,
view,
},
},
});
*/
this._emit( 'view_changed', {
previous,
view
});
}
}, },
load: async function() { load: async function() {