Compare commits

..

2 Commits

Author SHA1 Message Date
Julien Calixte
002cf9a4b1 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.
2026-05-03 23:37:28 +02:00
Julien Calixte
efe9c01e63 chore(github-content): pin api version on fetchLatestSha request
Silences the @octokit/request deprecation warning that prints whenever
the unversioned /repos/{owner}/{repo}/contents/{path} call fires.
2026-05-03 23:37:24 +02:00
2 changed files with 26 additions and 2 deletions

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"

View File

@@ -16,7 +16,12 @@ export const useGitHubContent = ({
const octokit = await getOctokit() const octokit = await getOctokit()
const response = await octokit.request( const response = await octokit.request(
"GET /repos/{owner}/{repo}/contents/{path}", "GET /repos/{owner}/{repo}/contents/{path}",
{ owner: user, repo, path } {
owner: user,
repo,
path,
headers: { "X-GitHub-Api-Version": "2022-11-28" }
}
) )
const data = response?.data const data = response?.data
if (Array.isArray(data) || !data) return null if (Array.isArray(data) || !data) return null