fixed sonarqube findings
This commit is contained in:
+23
-21
@@ -22,12 +22,12 @@ globalThis.Wegwichtel ??= {};
|
||||
button.addEventListener('pointerup', event => {
|
||||
if (event.isPrimary === false || (event.button && event.button !== 0)) return;
|
||||
event.preventDefault();
|
||||
void action();
|
||||
action();
|
||||
});
|
||||
button.addEventListener('keydown', event => {
|
||||
if (!['Enter', ' '].includes(event.key)) return;
|
||||
event.preventDefault();
|
||||
void action();
|
||||
action();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ globalThis.Wegwichtel ??= {};
|
||||
|
||||
function openEntry() {
|
||||
dialogGeneration += 1;
|
||||
selection = Array(codeLength).fill(0);
|
||||
selection = new Array(codeLength).fill(0);
|
||||
element(ids.status).textContent = '';
|
||||
element(ids.entry).hidden = false;
|
||||
element(ids.invitation).hidden = true;
|
||||
@@ -297,34 +297,36 @@ globalThis.Wegwichtel ??= {};
|
||||
if (routeId && revision !== null && /^\d+$/.test(revision)) revisions.set(routeId, Number(revision));
|
||||
}
|
||||
|
||||
async function joinSelectedGroup() {
|
||||
const generation = dialogGeneration;
|
||||
const motifs = ns.GroupSymbols.list();
|
||||
let payload;
|
||||
try {
|
||||
payload = await request('/join', 'POST', {
|
||||
code: selection.map(index => motifs[index].unicode), creator_id: ns.LocalRoutes.creatorId()
|
||||
});
|
||||
} catch (error) {
|
||||
if (!element(ids.dialog).open || generation !== dialogGeneration) return;
|
||||
throw error;
|
||||
}
|
||||
if (!element(ids.dialog).open || generation !== dialogGeneration) return;
|
||||
await edit(payload.group);
|
||||
await refresh();
|
||||
}
|
||||
|
||||
function init() {
|
||||
globalThis.setInterval?.(() => { void refreshInvitation(); }, 30_000);
|
||||
globalThis.setInterval?.(() => { refreshInvitation(); }, 30_000);
|
||||
activate(element('group-share-start'), () => finishShare(true));
|
||||
activate(element('group-share-close'), () => finishShare(false));
|
||||
element('group-share-dialog').addEventListener('close', () => {
|
||||
const resolve = shareDecision; shareDecision = null; resolve?.(false);
|
||||
});
|
||||
document.addEventListener('wegwichtel:point-drafts-changed', () => { void renderPending(); void ns.StorageUsage?.refresh(); });
|
||||
document.addEventListener('wegwichtel:point-drafts-changed', () => { renderPending(); ns.StorageUsage?.refresh(); });
|
||||
element(ids.dialog).addEventListener('cancel', () => { dialogGeneration += 1; });
|
||||
element(ids.dialog).addEventListener('close', () => { dialogGeneration += 1; });
|
||||
for (const id of [ids.joinOpen, ids.editorJoin]) activate(element(id), openEntry);
|
||||
activate(element(ids.close), () => element(ids.dialog).close());
|
||||
activate(element(ids.join), () => guarded(async () => {
|
||||
const generation = dialogGeneration;
|
||||
const motifs = ns.GroupSymbols.list();
|
||||
let payload;
|
||||
try {
|
||||
payload = await request('/join', 'POST', {
|
||||
code: selection.map(index => motifs[index].unicode), creator_id: ns.LocalRoutes.creatorId()
|
||||
});
|
||||
} catch (error) {
|
||||
if (!element(ids.dialog).open || generation !== dialogGeneration) return;
|
||||
throw error;
|
||||
}
|
||||
if (!element(ids.dialog).open || generation !== dialogGeneration) return;
|
||||
await edit(payload.group);
|
||||
await refresh();
|
||||
}));
|
||||
activate(element(ids.join), () => guarded(joinSelectedGroup));
|
||||
activate(element(ids.edit), () => guarded(() => edit(currentGroup)));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user