fix(stacked-note): act on outdated badge clicks

Clicking the badge while it shows outdated now pulls the latest version
from GitHub when there are no unsaved edits, or opens the conflict
modal when edits are in flight. Previously the click only re-ran the
same freshness check, so the badge appeared dead.
This commit is contained in:
Julien Calixte
2026-05-03 23:37:28 +02:00
parent efe9c01e63
commit 002cf9a4b1

View File

@@ -239,6 +239,25 @@ const onConflictOverwrite = async () => {
const onConflictCancel = () => { const onConflictCancel = () => {
if (mode.value === "read") toggleMode() if (mode.value === "read") toggleMode()
} }
const onBadgeClick = async () => {
if (freshnessStatus.value !== "outdated") {
await checkFreshness()
return
}
const hasUnsavedEdits = rawContent.value !== initialRawContent.value
if (hasUnsavedEdits) {
conflictOpen.value = true
return
}
const newRaw = await pullLatest()
if (newRaw !== null) {
rawContent.value = newRaw
initialRawContent.value = newRaw
}
}
</script> </script>
<template> <template>
@@ -270,7 +289,7 @@ const onConflictCancel = () => {
<note-freshness-badge <note-freshness-badge
:status="freshnessStatus" :status="freshnessStatus"
:last-checked-at="lastCheckedAt" :last-checked-at="lastCheckedAt"
@click="checkFreshness" @click="onBadgeClick"
/> />
<button <button
v-if="isMarkdown" v-if="isMarkdown"