activity: pseudo links work on click

This commit is contained in:
Harvey Tindall
2023-10-22 14:02:22 +01:00
parent d00f3fcfbc
commit 0238c6778c
5 changed files with 70 additions and 4 deletions
+16 -1
View File
@@ -261,6 +261,8 @@ class DOMInvite implements Invite {
}
}
focus = () => this._container.scrollIntoView({ behavior: "smooth", block: "center" });
constructor(invite: Invite) {
// first create the invite structure, then use our setter methods to fill in the data.
this._container = document.createElement('div') as HTMLDivElement;
@@ -423,6 +425,16 @@ export class inviteList implements inviteList {
invites: { [code: string]: DOMInvite };
public static readonly _inviteURLEvent = "invite-url";
registerURLListener = () => document.addEventListener(inviteList._inviteURLEvent, (event: CustomEvent) => {
const inviteCode = event.detail;
for (let code of Object.keys(this.invites)) {
this.invites[code].expanded = code == inviteCode;
}
if (inviteCode in this.invites) this.invites[inviteCode].focus();
else window.notifications.customError("inviteDoesntExistError", window.lang.notif("errorInviteDoesntExist"));
})
constructor() {
this._list = document.getElementById('invites') as HTMLDivElement;
this.empty = true;
@@ -436,6 +448,8 @@ export class inviteList implements inviteList {
this.empty = true;
}
}, false);
this.registerURLListener();
}
get empty(): boolean { return this._empty; }
@@ -500,7 +514,8 @@ export class inviteList implements inviteList {
}
})
}
export const inviteURLEvent = (id: string) => { return new CustomEvent(inviteList._inviteURLEvent, {"detail": id}) };
function parseInvite(invite: { [f: string]: string | number | { [name: string]: number } | boolean }): Invite {
let parsed: Invite = {};