Skip to content

Commit 56c1415

Browse files
committed
better keybind navigation
1 parent e038982 commit 56c1415

3 files changed

Lines changed: 23 additions & 14 deletions

File tree

‎apps/frontend/src/components/ui/moderation/checklist/ModerationChecklist.vue‎

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@
291291

292292
<div v-else-if="generatedMessage" class="flex items-center gap-2">
293293
<ButtonStyled>
294-
<button :disabled="loadingModerationDecision" @click="goBackToStages">
294+
<button :disabled="loadingModerationDecision" @click="previousStage">
295295
<LeftArrowIcon aria-hidden="true" />
296296
Edit
297297
</button>
@@ -340,13 +340,15 @@
340340
<LeftArrowIcon aria-hidden="true" /> Previous
341341
</button>
342342
</ButtonStyled>
343-
<ButtonStyled v-if="!isLastVisibleStage" color="brand">
344-
<button @click="nextStage"><RightArrowIcon aria-hidden="true" /> Next</button>
345-
</ButtonStyled>
346-
<ButtonStyled v-else color="brand" :disabled="loadingMessage">
347-
<button @click="generateMessage">
348-
<CheckIcon aria-hidden="true" />
349-
{{ loadingMessage ? 'Generating...' : 'Generate Message' }}
343+
<ButtonStyled color="brand" :disabled="isLastVisibleStage && loadingMessage">
344+
<button @click="nextStage">
345+
<template v-if="isLastVisibleStage">
346+
<CheckIcon aria-hidden="true" />
347+
{{ loadingMessage ? 'Generating...' : 'Generate Message' }}
348+
</template>
349+
<template v-else>
350+
<RightArrowIcon aria-hidden="true" /> Next
351+
</template>
350352
</button>
351353
</ButtonStyled>
352354
</div>
@@ -1259,7 +1261,7 @@ function handleKeybinds(event: KeyboardEvent) {
12591261
tryApprove: () => sendMessage(approveSendStatus.value),
12601262
tryReject: () => sendMessage('rejected'),
12611263
tryWithhold: () => sendMessage('withheld'),
1262-
tryEditMessage: goBackToStages,
1264+
tryEditMessage: previousStage,
12631265
12641266
tryCopyLink: async (permalink: boolean, relative: boolean, page: boolean) => {
12651267
let url = ``
@@ -1511,8 +1513,12 @@ function shouldShowStageIndex(stageIndex: number): boolean {
15111513
}
15121514
15131515
function previousStage() {
1514-
let targetStage = currentStage.value - 1
1516+
if (generatedMessage.value) {
1517+
goBackToStages()
1518+
return
1519+
}
15151520
1521+
let targetStage = currentStage.value - 1
15161522
while (targetStage >= 0) {
15171523
if (shouldShowStageIndex(targetStage)) {
15181524
currentStage.value = targetStage
@@ -1523,15 +1529,18 @@ function previousStage() {
15231529
}
15241530
15251531
function nextStage() {
1526-
let targetStage = currentStage.value + 1
1532+
if (generatedMessage.value) return
15271533
1534+
let targetStage = currentStage.value + 1
15281535
while (targetStage < resolvedStages.value.length) {
15291536
if (shouldShowStageIndex(targetStage)) {
15301537
currentStage.value = targetStage
15311538
return
15321539
}
15331540
targetStage++
15341541
}
1542+
1543+
generateMessage()
15351544
}
15361545
15371546
function goBackToStages() {

‎packages/moderation/src/data/keybinds.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ const keybinds: { [id: string]: KeybindListener } = {
44
'next-stage': {
55
keybind: 'ArrowRight',
66
description: 'Go to next stage',
7-
enabled: (ctx) => !ctx.state.isDone && !ctx.state.hasGeneratedMessage,
7+
enabled: (ctx) => !ctx.state.isDone,
88
action: (ctx) => ctx.actions.tryGoNext(),
99
},
1010
'previous-stage': {
1111
keybind: 'ArrowLeft',
1212
description: 'Go to previous stage',
13-
enabled: (ctx) => !ctx.state.isDone && !ctx.state.hasGeneratedMessage,
13+
enabled: (ctx) => !ctx.state.isDone,
1414
action: (ctx) => ctx.actions.tryGoBack(),
1515
},
1616
'generate-message': {

‎packages/moderation/src/data/stages/title-slug.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export default function () {
4747
let slugDebounceTimer: ReturnType<typeof setTimeout> | undefined
4848

4949
function currentSlug(state: Record<string, NodeState>) {
50-
return (state['correct-slug'] as string | undefined) ?? project.value.slug
50+
return (state['correct-slug'] as string | undefined) ?? resolvedAutoSlug.value ?? project.value.slug
5151
}
5252

5353
async function checkSlugTaken(slug: string): Promise<Labrinth.Projects.v3.Project | null> {

0 commit comments

Comments
 (0)