feat(nds): fix missing @activate-a event handlers

This commit is contained in:
2026-02-13 00:08:23 +01:00
parent a5424993b3
commit f6ca995643
4 changed files with 48 additions and 27 deletions

View File

@@ -68,33 +68,7 @@ const { selected, pressed, selectorPosition } = useButtonNavigation({
},
},
initialButton: "git",
onActivate: async (button) => {
const { action, url } = BUTTONS[button];
const verb = $t(`contact.actions.${button}`);
if (action === "copy") {
try {
await navigator.clipboard.writeText(url);
store.pushNotification($t("contact.copiedToClipboard", { item: verb }));
} catch (error) {
console.error("Failed to copy to clipboard:", error);
}
} else {
confirmationModal.open({
text: $t("contact.openUrl", { url: url.replace(/^https?:\/\//, "") }),
onActivateA: async () => {
store.pushNotification($t("contact.opened", { item: verb }));
await promiseTimeout(100);
await navigateTo(url, { open: { target: "_blank " } });
await promiseTimeout(500);
if (button === "git") {
achievements.unlock("contact_git_visit");
}
},
});
}
},
onActivate: (button) => handleActivateA(button),
disabled: computed(() => store.isIntro || store.isOutro),
selectorAnimation: {
duration: 0.075,
@@ -102,6 +76,34 @@ const { selected, pressed, selectorPosition } = useButtonNavigation({
},
});
const handleActivateA = async (button: typeof selected.value) => {
const { action, url } = BUTTONS[button];
const verb = $t(`contact.actions.${button}`);
if (action === "copy") {
try {
await navigator.clipboard.writeText(url);
store.pushNotification($t("contact.copiedToClipboard", { item: verb }));
} catch (error) {
console.error("Failed to copy to clipboard:", error);
}
} else {
confirmationModal.open({
text: $t("contact.openUrl", { url: url.replace(/^https?:\/\//, "") }),
onActivateA: async () => {
store.pushNotification($t("contact.opened", { item: verb }));
await promiseTimeout(100);
await navigateTo(url, { open: { target: "_blank " } });
await promiseTimeout(500);
if (button === "git") {
achievements.unlock("contact_git_visit");
}
},
});
}
};
const handleActivateB = () => {
if (store.isIntro || store.isOutro) return;
store.animateOutro();
@@ -157,6 +159,7 @@ onRender((ctx) => {
"
:b-label="$t('common.quit')"
:a-label="$t(`contact.actions.${BUTTONS[selected].action}`)"
@activate-a="handleActivateA(selected)"
@activate-b="handleActivateB"
/>
</template>

View File

@@ -250,6 +250,21 @@ const selectorTransitionOffsetY = computed(() => {
return store.submenuTransition.offsetY;
});
const handleActivateA = () => {
if (store.isIntro || store.isOutro || store.submenuTransition.opacity < 1)
return;
if (isSubMenu(selected.value)) {
store.openSubMenu(selected.value);
} else {
if (selected.value === "options") select("optionsLanguage");
if (selected.value === "clock") select("clockAchievements");
if (selected.value === "user") select("userUserName");
if (selected.value === "touchScreen")
store.openSubMenu("touchScreenTapTap");
}
};
const handleActivateB = () => {
if (store.isIntro || store.isOutro || store.submenuTransition.opacity < 1)
return;
@@ -318,6 +333,7 @@ const handleActivateB = () => {
:y-offset="store.barOffsetY + store.submenuButtonsOffsetY"
:b-label="isSubmenuSelected ? $t('common.goBack') : $t('common.quit')"
:a-label="$t('common.select')"
@activate-a="handleActivateA()"
@activate-b="handleActivateB()"
/>
</template>

View File

@@ -225,6 +225,7 @@ defineOptions({
:y-offset="confirmationModal.buttonsYOffset + store.submenuButtonsOffsetY"
:b-label="bLabel"
:a-label="aLabel"
@activate-a="handleActivateA"
@activate-b="handleActivateB"
/>

View File

@@ -196,6 +196,7 @@ onRender((ctx) => {
:y-offset="confirmationModal.buttonsYOffset + store.submenuButtonsOffsetY"
:b-label="bLabel"
:a-label="aLabel"
@activate-a="handleActivateA"
@activate-b="handleActivateB"
/>