= {}
try {
@@ -120,6 +124,17 @@ export const useUserRepoStore = defineStore("USER_REPO_STATE", {
if (requestId !== this._requestId) return
+ getRepoPermission(user, repo)
+ .then((canPush) => {
+ if (requestId !== this._requestId) return
+ this.canPush = canPush
+ })
+ .catch((error) => {
+ if (requestId !== this._requestId) return
+ console.warn("getRepoPermission failed", error)
+ this.canPush = false
+ })
+
getFiles(user, repo)
.then(async (files) => {
if (requestId !== this._requestId) return
@@ -261,6 +276,7 @@ export const useUserRepoStore = defineStore("USER_REPO_STATE", {
resetFiles() {
this.files = []
this.readme = null
+ this.canPush = false
},
setFontFamily(fontFamily: string) {
if (!this.userSettings) {
diff --git a/src/views/FleetingNotes.vue b/src/views/FleetingNotes.vue
index 853fe13..35cde7d 100644
--- a/src/views/FleetingNotes.vue
+++ b/src/views/FleetingNotes.vue
@@ -9,6 +9,7 @@ import { useRouteQueryStackedNotes } from "@/hooks/useRouteQueryStackedNotes.hoo
import { prepareNoteCache } from "@/modules/note/cache/prepareNoteCache"
import EditNote from "@/modules/note/components/EditNote.vue"
import { useFolderNotes } from "@/modules/note/hooks/useFolderNotes"
+import { useUserRepoStore } from "@/modules/repo/store/userRepo.store"
import { encodeUTF8ToBase64 } from "@/utils/decodeBase64ToUTF8"
import { confirmMessage, errorMessage } from "@/utils/notif"
import { extractYouTubeId } from "@/utils/youtube"
@@ -76,6 +77,9 @@ const { createFile } = useGitHubContent({
const hasTodayNote = computed(() => content.value.includes(today))
+const store = useUserRepoStore()
+const canPush = computed(() => store.canPush)
+
watch(mode, async (newMode) => {
if (newMode === "read" && newContent.value.trim() !== initialContent) {
const content = `# ${new Date().toLocaleDateString()}\n\n${
@@ -114,13 +118,15 @@ watch(mode, async (newMode) => {
Inbox
-
+
diff --git a/src/views/TodoNotes.vue b/src/views/TodoNotes.vue
index 59a9d22..27c1ab3 100644
--- a/src/views/TodoNotes.vue
+++ b/src/views/TodoNotes.vue
@@ -26,9 +26,10 @@ const todoNote = computed(() =>
const sha = computed(() => todoNote.value?.sha ?? "")
const path = computed(() => todoNote.value?.path)
+const canPush = computed(() => store.canPush)
+
const { toHTML } = markdownBuilder(repo)
-// Setup checkbox commit handler
const { pendingContent, syncContent, listenToCheckboxes, hasPendingChanges } =
useCheckboxCommit({
user: props.user,
@@ -37,7 +38,8 @@ const { pendingContent, syncContent, listenToCheckboxes, hasPendingChanges } =
initialContent: "",
initialSha: sha,
containerSelector: ".todo-notes .note-display",
- debounceMs: 1000
+ debounceMs: 1000,
+ enabled: canPush
})
// Render pending content to HTML for display
@@ -64,9 +66,9 @@ watch(
{ immediate: true }
)
-// Setup checkbox listeners when content renders
+// Setup checkbox listeners when content renders or canPush changes
watch(
- renderedContent,
+ [renderedContent, canPush],
async () => {
await nextTick()
listenToCheckboxes()