@@ -109,8 +107,8 @@ import { useFavoriteRepos } from '@/modules/repo/hooks/useFavoriteRepos.hook'
import SignInGithub from '@/components/SignInGithub.vue'
export default defineComponent({
- components: { SignInGithub },
name: 'WelcomeWord',
+ components: { SignInGithub },
setup() {
const { isLogged, username } = useGitHubLogin()
const { savedFavoriteRepos } = useFavoriteRepos()
diff --git a/src/hooks/useGitHubLogin.hook.ts b/src/hooks/useGitHubLogin.hook.ts
index 7f76d13..71cfc14 100644
--- a/src/hooks/useGitHubLogin.hook.ts
+++ b/src/hooks/useGitHubLogin.hook.ts
@@ -1,33 +1,33 @@
import { computed, ref } from 'vue'
import { confirmMessage } from '@/utils/notif'
-import { GithubToken } from '@/modules/user/interfaces/GithubToken'
import { getAccessToken, saveAccessToken } from '@/modules/user/service/signIn'
+import { GithubToken } from '@/modules/user/interfaces/GithubToken'
const username = ref
(null)
const accessToken = ref(null)
let init = true
-export const useGitHubLogin = () => {
- const saveAccessTokenToLocal = async () => {
- const response = await getAccessToken()
- username.value = response?.username || ''
- accessToken.value = response?.token || ''
- }
+const saveAccessTokenToLocal = async () => {
+ const response = await getAccessToken()
+ username.value = response?.username || ''
+ accessToken.value = response?.token || ''
+}
+const saveCredentials = async (token: GithubToken): Promise => {
+ const accessToken = await saveAccessToken(token)
+
+ await saveAccessTokenToLocal()
+ confirmMessage(`${accessToken.username} is logged in!`)
+}
+
+export const useGitHubLogin = () => {
if (init) {
init = false
saveAccessTokenToLocal()
}
- const saveCredentials = async (githubToken: GithubToken) => {
- const accessToken = await saveAccessToken(githubToken)
-
- await saveAccessTokenToLocal()
- confirmMessage(`${accessToken.username} is logged in!`)
- }
-
return {
isLogged: !!accessToken.value,
isReady: computed(() => accessToken.value !== null),
diff --git a/src/hooks/useMarkdown.hook.ts b/src/hooks/useMarkdown.hook.ts
index 7a0f746..d4792c6 100644
--- a/src/hooks/useMarkdown.hook.ts
+++ b/src/hooks/useMarkdown.hook.ts
@@ -13,7 +13,7 @@ const md = new MarkdownIt({
h4: ['title', 'is-5'],
h5: ['title', 'is-6'],
h6: ['title', 'is-6'],
- table: ['table', 'is-striped', 'is-hoverable']
+ table: ['table', 'is-fullwidth']
})
.use(blockEmbedPlugin, {
youtube: {
diff --git a/src/hooks/useNote.hook.ts b/src/hooks/useNote.hook.ts
index 64948c9..fbb3637 100644
--- a/src/hooks/useNote.hook.ts
+++ b/src/hooks/useNote.hook.ts
@@ -100,8 +100,9 @@ export const useNote = (containerClass: string) => {
if (isMobile.value) {
container.style.height = `${(stackedNotes.value.length + 1) * 100}vh`
} else {
- container.style.width = `${NOTE_WIDTH *
- (stackedNotes.value.length + 1)}px`
+ container.style.width = `${
+ NOTE_WIDTH * (stackedNotes.value.length + 1)
+ }px`
}
}
diff --git a/src/hooks/useNoteOverlay.hook.ts b/src/hooks/useNoteOverlay.hook.ts
index 06ee23e..05304a7 100644
--- a/src/hooks/useNoteOverlay.hook.ts
+++ b/src/hooks/useNoteOverlay.hook.ts
@@ -39,10 +39,9 @@ export const useNoteOverlay = (className: string, index: number) => {
) as NodeListOf
stackedNoteContainers.forEach((stackedNote, ind) => {
- stackedNote.style.right = `calc(-${NOTE_WIDTH}px + ${(stackedNotes.value
- .length -
- ind) *
- BOOKMARK_WIDTH}rem)`
+ stackedNote.style.right = `calc(-${NOTE_WIDTH}px + ${
+ (stackedNotes.value.length - ind) * BOOKMARK_WIDTH
+ }rem)`
})
}
})
diff --git a/src/main.ts b/src/main.ts
index 521bc63..a1bf551 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -13,8 +13,4 @@ const i18n = createI18n({
messages
})
-createApp(App)
- .use(router)
- .use(i18n)
- .use(createPinia())
- .mount('#app')
+createApp(App).use(router).use(i18n).use(createPinia()).mount('#app')
diff --git a/src/modules/note/hooks/useFolderNotes.ts b/src/modules/note/hooks/useFolderNotes.ts
index 65e7707..5125782 100644
--- a/src/modules/note/hooks/useFolderNotes.ts
+++ b/src/modules/note/hooks/useFolderNotes.ts
@@ -1,32 +1,32 @@
-import { useUserRepoStore } from '@/modules/repo/store/userRepo.store'
-import { computed } from 'vue'
-
-export const useFolderNotes = (folders: string[]) => {
- const store = useUserRepoStore()
-
- const fleetingNotes = computed(() =>
- store.files.filter(
- (file) =>
- folders.some((folder) => file.path?.startsWith(folder)) &&
- file.path?.endsWith('.md')
- )
- )
-
- const content = computed(() =>
- fleetingNotes.value?.length > 0
- ? fleetingNotes.value
- .map((note) => {
- const firstFolder = note.path?.split('/').shift()
-
- return `- [${note.path?.replace(`${firstFolder}/`, '')}](${
- note.path
- })`
- })
- .join('\n')
- : ''
- )
-
- return {
- content
- }
-}
+import { useUserRepoStore } from '@/modules/repo/store/userRepo.store'
+import { computed } from 'vue'
+
+export const useFolderNotes = (folders: string[]) => {
+ const store = useUserRepoStore()
+
+ const fleetingNotes = computed(() =>
+ store.files.filter(
+ (file) =>
+ folders.some((folder) => file.path?.startsWith(folder)) &&
+ file.path?.endsWith('.md')
+ )
+ )
+
+ const content = computed(() =>
+ fleetingNotes.value?.length > 0
+ ? fleetingNotes.value
+ .map((note) => {
+ const firstFolder = note.path?.split('/').shift()
+
+ return `- [${note.path?.replace(`${firstFolder}/`, '')}](${
+ note.path
+ })`
+ })
+ .join('\n')
+ : ''
+ )
+
+ return {
+ content
+ }
+}
diff --git a/src/modules/note/hooks/useNoteCache.ts b/src/modules/note/hooks/useNoteCache.ts
index fad2d05..1f86f96 100644
--- a/src/modules/note/hooks/useNoteCache.ts
+++ b/src/modules/note/hooks/useNoteCache.ts
@@ -1,31 +1,31 @@
-import { data } from '@/data/data'
-import { DataType } from '@/data/DataType.enum'
-import { Note } from '@/modules/note/models/Note'
-import { useAsyncState } from '@vueuse/core'
-import { computed } from 'vue'
-
-export const useNoteCache = (sha: string) => {
- const noteId = computed(() => data.generateId(DataType.Note, sha))
- const getCachedNote = async () => data.get(noteId.value)
-
- const cachedNote = useAsyncState(getCachedNote, null)
-
- const saveCacheNote = async (content: string) => {
- const newNote: Note = {
- _id: noteId.value,
- $type: DataType.Note,
- content
- }
-
- await data.update(newNote)
-
- await cachedNote.execute()
- }
-
- return {
- cachedNote: cachedNote.state,
- isReady: cachedNote.isReady,
- getCachedNote,
- saveCacheNote
- }
-}
+import { data } from '@/data/data'
+import { DataType } from '@/data/DataType.enum'
+import { Note } from '@/modules/note/models/Note'
+import { useAsyncState } from '@vueuse/core'
+import { computed } from 'vue'
+
+export const useNoteCache = (sha: string) => {
+ const noteId = computed(() => data.generateId(DataType.Note, sha))
+ const getCachedNote = async () => data.get(noteId.value)
+
+ const cachedNote = useAsyncState(getCachedNote, null)
+
+ const saveCacheNote = async (content: string) => {
+ const newNote: Note = {
+ _id: noteId.value,
+ $type: DataType.Note,
+ content
+ }
+
+ await data.update(newNote)
+
+ await cachedNote.execute()
+ }
+
+ return {
+ cachedNote: cachedNote.state,
+ isReady: cachedNote.isReady,
+ getCachedNote,
+ saveCacheNote
+ }
+}
diff --git a/src/modules/note/models/Note.ts b/src/modules/note/models/Note.ts
index 9f80879..f88d920 100644
--- a/src/modules/note/models/Note.ts
+++ b/src/modules/note/models/Note.ts
@@ -1,6 +1,6 @@
-import { DataType } from '@/data/DataType.enum'
-import { Model } from '@/data/models/Model'
-
-export interface Note extends Model {
- content: string
-}
+import { DataType } from '@/data/DataType.enum'
+import { Model } from '@/data/models/Model'
+
+export interface Note extends Model {
+ content: string
+}
diff --git a/src/modules/repo/services/resolvePath.ts b/src/modules/repo/services/resolvePath.ts
index 1b37cec..5aada86 100644
--- a/src/modules/repo/services/resolvePath.ts
+++ b/src/modules/repo/services/resolvePath.ts
@@ -1,32 +1,32 @@
-const sanitizePath = (path: string) => {
- if (path.startsWith('./')) {
- return decodeURIComponent(path.replace('./', ''))
- }
- return decodeURIComponent(path)
-}
-
-const removeNoteFilename = (pathNote: string) => {
- const path = pathNote.split('/')
- path.pop()
-
- return sanitizePath(path.join('/'))
-}
-
-export const resolvePath = (
- currentAbsolutePathNote: string,
- pathToResolve: string
-) => {
- let currentAbsolutePath = removeNoteFilename(currentAbsolutePathNote)
- pathToResolve = sanitizePath(pathToResolve)
-
- while (pathToResolve.startsWith('../')) {
- const adjustedAbsolutePath = currentAbsolutePath.split('/')
- adjustedAbsolutePath.pop()
- currentAbsolutePath = adjustedAbsolutePath.join('/')
- pathToResolve = pathToResolve.replace('../', '')
- }
-
- return currentAbsolutePath
- ? `${currentAbsolutePath}/${pathToResolve}`
- : pathToResolve
-}
+const sanitizePath = (path: string) => {
+ if (path.startsWith('./')) {
+ return decodeURIComponent(path.replace('./', ''))
+ }
+ return decodeURIComponent(path)
+}
+
+const removeNoteFilename = (pathNote: string) => {
+ const path = pathNote.split('/')
+ path.pop()
+
+ return sanitizePath(path.join('/'))
+}
+
+export const resolvePath = (
+ currentAbsolutePathNote: string,
+ pathToResolve: string
+) => {
+ let currentAbsolutePath = removeNoteFilename(currentAbsolutePathNote)
+ pathToResolve = sanitizePath(pathToResolve)
+
+ while (pathToResolve.startsWith('../')) {
+ const adjustedAbsolutePath = currentAbsolutePath.split('/')
+ adjustedAbsolutePath.pop()
+ currentAbsolutePath = adjustedAbsolutePath.join('/')
+ pathToResolve = pathToResolve.replace('../', '')
+ }
+
+ return currentAbsolutePath
+ ? `${currentAbsolutePath}/${pathToResolve}`
+ : pathToResolve
+}
diff --git a/src/modules/repo/store/userRepo.store.ts b/src/modules/repo/store/userRepo.store.ts
index 7d5da19..f4d844a 100644
--- a/src/modules/repo/store/userRepo.store.ts
+++ b/src/modules/repo/store/userRepo.store.ts
@@ -5,7 +5,6 @@ import {
getMainReadme,
getUserSettingsContent
} from '@/modules/repo/services/repo'
-import { refreshToken } from '@/modules/user/service/signIn'
import { defineStore } from 'pinia'
interface State {
@@ -29,7 +28,6 @@ export const useUserRepoStore = defineStore({
async setUserRepo(newUser: string, newRepo: string) {
this.user = newUser
this.repo = newRepo
- await refreshToken()
const [readme, files] = await Promise.all([
getMainReadme(newUser, newRepo),
getFiles(newUser, newRepo)
diff --git a/src/modules/user/service/signIn.ts b/src/modules/user/service/signIn.ts
index c8a141d..bd2389c 100644
--- a/src/modules/user/service/signIn.ts
+++ b/src/modules/user/service/signIn.ts
@@ -58,8 +58,6 @@ export const refreshToken = async () => {
| GithubToken
| GithubTokenError
- console.log(githubToken)
-
if ('error' in githubToken) {
return null
}
@@ -105,8 +103,6 @@ export const saveAccessToken = async (githubToken: GithubToken) => {
username: ''
}
- console.log(accessToken)
-
const octokit = new Octokit({
auth: accessToken?.token
})
diff --git a/src/views/DraftNotes.vue b/src/views/DraftNotes.vue
index 222b25d..8107221 100644
--- a/src/views/DraftNotes.vue
+++ b/src/views/DraftNotes.vue
@@ -1,47 +1,45 @@
-
-
-
-
- Drafts
-
-
-
-
-
-
-
-
+
+
+
+ Drafts
+
+
+
+
+
+
+
diff --git a/src/views/FleetingNotes.vue b/src/views/FleetingNotes.vue
index 4bd7e75..1ab5e94 100644
--- a/src/views/FleetingNotes.vue
+++ b/src/views/FleetingNotes.vue
@@ -1,52 +1,50 @@
-
-
-
-
- Inbox
-
-
-
-
-
-
-
-
+
+
+
+ Inbox
+
+
+
+
+
+
+
diff --git a/src/views/Home.vue b/src/views/Home.vue
index ffa089b..fae44b1 100644
--- a/src/views/Home.vue
+++ b/src/views/Home.vue
@@ -34,6 +34,9 @@ export default defineComponent({
},
setup(props) {
const { resetStackedNotes } = useQueryStackedNotes()
+ onMounted(() => {
+ refreshToken()
+ })
onMounted(() => {
refreshToken()
diff --git a/src/views/Login.vue b/src/views/Login.vue
index 46d9d54..1841404 100644
--- a/src/views/Login.vue
+++ b/src/views/Login.vue
@@ -13,10 +13,10 @@
@@ -28,10 +28,10 @@
diff --git a/src/views/RepoList.vue b/src/views/RepoList.vue
index 5e2dad8..4e1a479 100644
--- a/src/views/RepoList.vue
+++ b/src/views/RepoList.vue
@@ -6,8 +6,8 @@
diff --git a/src/views/ShareNotes.vue b/src/views/ShareNotes.vue
index 90eb36e..668239c 100644
--- a/src/views/ShareNotes.vue
+++ b/src/views/ShareNotes.vue
@@ -6,10 +6,10 @@
diff --git a/tests/unit/modules/repo/services/resolvePath.spec.ts b/tests/unit/modules/repo/services/resolvePath.spec.ts
index 207fdb4..ee165f8 100644
--- a/tests/unit/modules/repo/services/resolvePath.spec.ts
+++ b/tests/unit/modules/repo/services/resolvePath.spec.ts
@@ -1,41 +1,41 @@
-import { resolvePath } from '@/modules/repo/services/resolvePath'
-
-describe('resolve path service', () => {
- it('set the absolute path if path to resolve is empty', () => {
- expect(resolvePath('standard/README.md', '')).toEqual('standard/')
- })
-
- it('returns the path sanitized if there is no absolute path', () => {
- expect(resolvePath('', './here/note.md')).toEqual('here/note.md')
- })
-
- it('set the absolute path from the current path', () => {
- expect(resolvePath('standard/README.md', './other-note.md')).toEqual(
- 'standard/other-note.md'
- )
- })
-
- it('set the absolute path from the current path with multiple level', () => {
- expect(
- resolvePath('standard/you/are/here/README.md', './other-note.md')
- ).toEqual('standard/you/are/here/other-note.md')
- })
-
- it('set the absolute path from the current path with a go back in the relative path', () => {
- expect(
- resolvePath('standard/you/are/here/README.md', '../other-note.md')
- ).toEqual('standard/you/are/other-note.md')
-
- expect(
- resolvePath('standard/you/are/here/README.md', '../../other-note.md')
- ).toEqual('standard/you/other-note.md')
-
- expect(
- resolvePath('standard/you/are/here/README.md', './../../other-note.md')
- ).toEqual('standard/you/other-note.md')
-
- expect(
- resolvePath('standard/you/are/here/README.md', './../../../other-note.md')
- ).toEqual('standard/other-note.md')
- })
-})
+import { resolvePath } from '@/modules/repo/services/resolvePath'
+
+describe('resolve path service', () => {
+ it('set the absolute path if path to resolve is empty', () => {
+ expect(resolvePath('standard/README.md', '')).toEqual('standard/')
+ })
+
+ it('returns the path sanitized if there is no absolute path', () => {
+ expect(resolvePath('', './here/note.md')).toEqual('here/note.md')
+ })
+
+ it('set the absolute path from the current path', () => {
+ expect(resolvePath('standard/README.md', './other-note.md')).toEqual(
+ 'standard/other-note.md'
+ )
+ })
+
+ it('set the absolute path from the current path with multiple level', () => {
+ expect(
+ resolvePath('standard/you/are/here/README.md', './other-note.md')
+ ).toEqual('standard/you/are/here/other-note.md')
+ })
+
+ it('set the absolute path from the current path with a go back in the relative path', () => {
+ expect(
+ resolvePath('standard/you/are/here/README.md', '../other-note.md')
+ ).toEqual('standard/you/are/other-note.md')
+
+ expect(
+ resolvePath('standard/you/are/here/README.md', '../../other-note.md')
+ ).toEqual('standard/you/other-note.md')
+
+ expect(
+ resolvePath('standard/you/are/here/README.md', './../../other-note.md')
+ ).toEqual('standard/you/other-note.md')
+
+ expect(
+ resolvePath('standard/you/are/here/README.md', './../../../other-note.md')
+ ).toEqual('standard/other-note.md')
+ })
+})