refactor(notes): return failure status from pullLatest

Callers had to read back the side-effected status ref to know why a
pull failed, which also broke TS narrowing on the freshness badge
handler. Return { raw, failureStatus } so the reason flows through
the return value.
This commit is contained in:
Julien Calixte
2026-05-25 21:25:54 +02:00
parent 60e3849c20
commit 54c52feeba
2 changed files with 17 additions and 14 deletions

View File

@@ -236,10 +236,10 @@ watch(mode, async (newMode) => {
})
const onConflictDiscard = async () => {
const newRaw = await pullLatest()
if (newRaw !== null) {
rawContent.value = newRaw
initialRawContent.value = newRaw
const { raw } = await pullLatest()
if (raw !== null) {
rawContent.value = raw
initialRawContent.value = raw
}
}
@@ -269,13 +269,13 @@ const onBadgeClick = async () => {
return
}
const newRaw = await pullLatest()
if (newRaw !== null) {
rawContent.value = newRaw
initialRawContent.value = newRaw
const { raw, failureStatus } = await pullLatest()
if (raw !== null) {
rawContent.value = raw
initialRawContent.value = raw
return
}
if (freshnessStatus.value === "unauthorized") {
if (failureStatus === "unauthorized") {
errorMessage("🔐 GitHub auth expired — please sign in again")
}
} catch (error) {