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

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

View File

@@ -68,33 +68,7 @@ const { selected, pressed, selectorPosition } = useButtonNavigation({
}, },
}, },
initialButton: "git", initialButton: "git",
onActivate: async (button) => { onActivate: (button) => handleActivateA(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");
}
},
});
}
},
disabled: computed(() => store.isIntro || store.isOutro), disabled: computed(() => store.isIntro || store.isOutro),
selectorAnimation: { selectorAnimation: {
duration: 0.075, 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 = () => { const handleActivateB = () => {
if (store.isIntro || store.isOutro) return; if (store.isIntro || store.isOutro) return;
store.animateOutro(); store.animateOutro();
@@ -157,6 +159,7 @@ onRender((ctx) => {
" "
:b-label="$t('common.quit')" :b-label="$t('common.quit')"
:a-label="$t(`contact.actions.${BUTTONS[selected].action}`)" :a-label="$t(`contact.actions.${BUTTONS[selected].action}`)"
@activate-a="handleActivateA(selected)"
@activate-b="handleActivateB" @activate-b="handleActivateB"
/> />
</template> </template>

View File

@@ -250,6 +250,21 @@ const selectorTransitionOffsetY = computed(() => {
return store.submenuTransition.offsetY; 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 = () => { const handleActivateB = () => {
if (store.isIntro || store.isOutro || store.submenuTransition.opacity < 1) if (store.isIntro || store.isOutro || store.submenuTransition.opacity < 1)
return; return;
@@ -318,6 +333,7 @@ const handleActivateB = () => {
:y-offset="store.barOffsetY + store.submenuButtonsOffsetY" :y-offset="store.barOffsetY + store.submenuButtonsOffsetY"
:b-label="isSubmenuSelected ? $t('common.goBack') : $t('common.quit')" :b-label="isSubmenuSelected ? $t('common.goBack') : $t('common.quit')"
:a-label="$t('common.select')" :a-label="$t('common.select')"
@activate-a="handleActivateA()"
@activate-b="handleActivateB()" @activate-b="handleActivateB()"
/> />
</template> </template>

View File

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

View File

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