diff --git a/src/components/StackedNote.vue b/src/components/StackedNote.vue index cbc1683..18d6323 100644 --- a/src/components/StackedNote.vue +++ b/src/components/StackedNote.vue @@ -1,5 +1,4 @@ diff --git a/src/hooks/useEditionMode.ts b/src/hooks/useEditionMode.ts new file mode 100644 index 0000000..b120ec2 --- /dev/null +++ b/src/hooks/useEditionMode.ts @@ -0,0 +1,22 @@ +import { useMagicKeys } from '@vueuse/core' +import { ref, watch } from 'vue' + +export const useEditionMode = () => { + const mode = ref<'read' | 'edit'>('read') + const toggleMode = () => { + mode.value = mode.value === 'read' ? 'edit' : 'read' + } + + const { escape } = useMagicKeys() + + watch(escape, () => { + if (mode.value === 'edit') { + toggleMode() + } + }) + + return { + mode, + toggleMode + } +} diff --git a/src/hooks/useGitHubUpdate.hook.ts b/src/hooks/useGitHubContent.hook.ts similarity index 76% rename from src/hooks/useGitHubUpdate.hook.ts rename to src/hooks/useGitHubContent.hook.ts index 08ed73a..f0fbfdc 100644 --- a/src/hooks/useGitHubUpdate.hook.ts +++ b/src/hooks/useGitHubContent.hook.ts @@ -2,21 +2,21 @@ import { getOctokit } from '@/modules/repo/services/octo' import { encodeUTF8ToBase64 } from '@/utils/decodeBase64ToUTF8' import { confirmMessage, errorMessage } from '@/utils/notif' -export const useGitHubUpdate = ({ +export const useGitHubContent = ({ user, repo }: { user: string repo: string }) => { - const updateFile = async ({ + const putFile = async ({ content, path, sha }: { content: string path: string - sha: string + sha?: string }) => { try { const octokit = await getOctokit() @@ -35,8 +35,6 @@ export const useGitHubUpdate = ({ confirmMessage('file saved on GitHub') - console.log(response) - return response?.data.content?.sha ?? null } catch (error) { errorMessage('File could not be saved') @@ -46,6 +44,9 @@ export const useGitHubUpdate = ({ } return { - updateFile + updateFile: async (props: { content: string; path: string; sha: string }) => + putFile(props), + createFile: async (props: { content: string; path: string }) => + putFile(props) } } diff --git a/src/hooks/useRouteQueryStackedNotes.hook.ts b/src/hooks/useRouteQueryStackedNotes.hook.ts index fdfae3b..805150f 100644 --- a/src/hooks/useRouteQueryStackedNotes.hook.ts +++ b/src/hooks/useRouteQueryStackedNotes.hook.ts @@ -41,10 +41,6 @@ export const useRouteQueryStackedNotes = () => { } const addStackedNote = (currentSHA: string, sha: string) => { - if (!stackedNotes.value) { - return - } - if (stackedNotes.value.includes(sha)) { scrollToFocusedNote(sha) return diff --git a/src/views/FleetingNotes.vue b/src/views/FleetingNotes.vue index 96da35e..28ac28f 100644 --- a/src/views/FleetingNotes.vue +++ b/src/views/FleetingNotes.vue @@ -1,11 +1,59 @@ @@ -17,6 +65,23 @@ const { content } = useFolderNotes(FLEETING_NOTES_FOLDER) :content="content" > Inbox + + + + new fleeting note + + + + + + + + + + + + + @@ -29,5 +94,10 @@ const { content } = useFolderNotes(FLEETING_NOTES_FOLDER) .subtitle { text-align: center; } + + .column { + display: flex; + justify-content: center; + } }