fix: clean up fixes after APP overhaul

This commit is contained in:
Andy Burke 2025-10-25 19:44:07 -07:00
parent 52f46207ec
commit c34069066d
11 changed files with 76 additions and 88 deletions

View file

@ -204,10 +204,6 @@ export async function POST(req: Request, meta: Record<string, any>): Promise<Res
});
}
console.dir({
event
});
await events.create(event);
return Response.json(event, {

View file

@ -10,7 +10,6 @@ import * as CANNED_RESPONSES from '../../../utils/canned_responses.ts';
import * as bcrypt from '@da/bcrypt';
import { INVITE_CODE, INVITE_CODES } from '../../../models/invites.ts';
// TODO: figure out a better solution for doling out permissions
const DEFAULT_USER_PERMISSIONS: string[] = [
'files.write.own',
@ -39,10 +38,16 @@ const DEFAULT_USER_PERMISSIONS: string[] = [
// TODO: figure out a better solution for doling out permissions
const DEFAULT_SUPERUSER_PERMISSIONS: string[] = [
...DEFAULT_USER_PERMISSIONS,
'topics.create',
'topics.delete',
'topics.write',
...DEFAULT_USER_PERMISSIONS,
'files.write.all',
'invites.read.all',
'signups.read.all',
'topics.create',
'topics.delete',
'topics.write',
'users.write',
'watches.read.all',
'watches.write.all'
];
export const PRECHECKS: PRECHECK_TABLE = {};

View file

@ -16,7 +16,7 @@
--border-highlight: hsl(from var(--base-color) h 50% 75%);
--icon-scale: 1;
--border-radius: 12px;
--border-radius: 4px;
}
@media (prefers-color-scheme: light) {

View file

@ -2,6 +2,7 @@ const HASH_EXTRACTOR = /^\#\/topic\/(?<topic_id>[A-Za-z\-]+)\/?(?<view>\w+)?/gm;
const UPDATE_TOPICS_FREQUENCY = 60_000;
const APP = {
user: undefined,
user_servers: [],
user_watches: [],
@ -56,16 +57,19 @@ const APP = {
groups: {},
};
/*
console.dir({
url: window.location.href,
hash: window.location.hash,
topic_id,
view,
});
*/
if (!document.body.dataset.topic || document.body.dataset.topic !== topic_id) {
const previous = document.body.dataset.topic;
/*
console.dir({
topic_changed: {
detail: {
@ -74,6 +78,7 @@ const APP = {
},
},
});
*/
document.body.dataset.topic = topic_id;
@ -94,6 +99,7 @@ const APP = {
const previous = document.body.dataset.view;
document.body.dataset.view = view;
/*
console.dir({
view_changed: {
detail: {
@ -102,6 +108,7 @@ const APP = {
},
},
});
*/
this._emit( 'view_changed', {
previous,
@ -149,8 +156,9 @@ const APP = {
this._emit( 'load', this );
},
update_user: async function( updated_user ) {
const user = this.user = updated_user;
update_user: async function( user ) {
this.user = user;
document.body.dataset.user = JSON.stringify(user);
document.body.dataset.perms = user.permissions.join(":");

View file

@ -809,9 +809,10 @@
form.on_reply = (new_topic) => {
const topic_list = document.getElementById("topic-list");
topic_list.querySelectorAll( 'li' ).forEach( (li) => li.classList.remove( 'active' ) );
topic_list.insertAdjacentHTML(
"beforeend",
`<li id="topic-selector-${new_topic.id}" class="topic"><a href="#/topic/${new_topic.id}">${new_topic.name}</a></li>`,
`<li id="topic-selector-${new_topic.id}" class="topic active"><a href="#/topic/${new_topic.id}">${new_topic.name}</a></li>`,
);
new_topic_name_input.value = "";

View file

@ -105,12 +105,7 @@
const form = document.currentScript.closest("form");
form.on_reply = (response) => {
const user = response.user;
document.body.dataset.user = JSON.stringify(user);
document.body.dataset.perms = user.permissions.join(":");
document.dispatchEvent(
new CustomEvent("user_logged_in", { detail: { user } }),
);
APP.login( user );
};
}
</script>