🚨 (app)
This commit is contained in:
@@ -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<string | null>(null)
|
||||
const accessToken = ref<string | null>(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<void> => {
|
||||
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),
|
||||
|
||||
@@ -29,7 +29,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)
|
||||
|
||||
@@ -1,47 +1,45 @@
|
||||
<template>
|
||||
<div class="draft-notes">
|
||||
<flux-note :user="user" :repo="repo" :content="content" key="draft-notes">
|
||||
<h3 class="subtitle is-3">
|
||||
Drafts
|
||||
</h3>
|
||||
</flux-note>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { useFolderNotes } from '@/modules/note/hooks/useFolderNotes'
|
||||
import { defineAsyncComponent, defineComponent } from 'vue'
|
||||
|
||||
const FluxNote = defineAsyncComponent(() => import('@/components/FluxNote.vue'))
|
||||
|
||||
const DRAFT_FOLDER = ['drafts', '_drafts']
|
||||
|
||||
export default defineComponent({
|
||||
name: 'DraftNotes',
|
||||
components: {
|
||||
FluxNote
|
||||
},
|
||||
props: {
|
||||
user: { type: String, required: true },
|
||||
repo: { type: String, required: true }
|
||||
},
|
||||
setup() {
|
||||
const { content } = useFolderNotes(DRAFT_FOLDER)
|
||||
|
||||
return {
|
||||
content
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.draft-notes {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
|
||||
.subtitle {
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<template>
|
||||
<div class="draft-notes">
|
||||
<flux-note key="draft-notes" :user="user" :repo="repo" :content="content">
|
||||
<h3 class="subtitle is-3">Drafts</h3>
|
||||
</flux-note>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { useFolderNotes } from '@/modules/note/hooks/useFolderNotes'
|
||||
import { defineAsyncComponent, defineComponent } from 'vue'
|
||||
|
||||
const FluxNote = defineAsyncComponent(() => import('@/components/FluxNote.vue'))
|
||||
|
||||
const DRAFT_FOLDER = ['drafts', '_drafts']
|
||||
|
||||
export default defineComponent({
|
||||
name: 'DraftNotes',
|
||||
components: {
|
||||
FluxNote
|
||||
},
|
||||
props: {
|
||||
user: { type: String, required: true },
|
||||
repo: { type: String, required: true }
|
||||
},
|
||||
setup() {
|
||||
const { content } = useFolderNotes(DRAFT_FOLDER)
|
||||
|
||||
return {
|
||||
content
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.draft-notes {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
|
||||
.subtitle {
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,52 +1,50 @@
|
||||
<template>
|
||||
<div class="fleeting-notes">
|
||||
<flux-note
|
||||
:user="user"
|
||||
:repo="repo"
|
||||
:content="content"
|
||||
key="fleeting-notes"
|
||||
>
|
||||
<h3 class="subtitle is-3">
|
||||
Inbox
|
||||
</h3>
|
||||
</flux-note>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { useFolderNotes } from '@/modules/note/hooks/useFolderNotes'
|
||||
import { defineAsyncComponent, defineComponent } from 'vue'
|
||||
|
||||
const FluxNote = defineAsyncComponent(() => import('@/components/FluxNote.vue'))
|
||||
|
||||
const FLEETING_NOTES_FOLDER = ['inbox', '_inbox']
|
||||
|
||||
export default defineComponent({
|
||||
name: 'FleetingNotes',
|
||||
components: {
|
||||
FluxNote
|
||||
},
|
||||
props: {
|
||||
user: { type: String, required: true },
|
||||
repo: { type: String, required: true }
|
||||
},
|
||||
setup() {
|
||||
const { content } = useFolderNotes(FLEETING_NOTES_FOLDER)
|
||||
|
||||
return {
|
||||
content
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.fleeting-notes {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
|
||||
.subtitle {
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<template>
|
||||
<div class="fleeting-notes">
|
||||
<flux-note
|
||||
key="fleeting-notes"
|
||||
:user="user"
|
||||
:repo="repo"
|
||||
:content="content"
|
||||
>
|
||||
<h3 class="subtitle is-3">Inbox</h3>
|
||||
</flux-note>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { useFolderNotes } from '@/modules/note/hooks/useFolderNotes'
|
||||
import { defineAsyncComponent, defineComponent } from 'vue'
|
||||
|
||||
const FluxNote = defineAsyncComponent(() => import('@/components/FluxNote.vue'))
|
||||
|
||||
const FLEETING_NOTES_FOLDER = ['inbox', '_inbox']
|
||||
|
||||
export default defineComponent({
|
||||
name: 'FleetingNotes',
|
||||
components: {
|
||||
FluxNote
|
||||
},
|
||||
props: {
|
||||
user: { type: String, required: true },
|
||||
repo: { type: String, required: true }
|
||||
},
|
||||
setup() {
|
||||
const { content } = useFolderNotes(FLEETING_NOTES_FOLDER)
|
||||
|
||||
return {
|
||||
content
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.fleeting-notes {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
|
||||
.subtitle {
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -8,10 +8,11 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent, defineAsyncComponent, computed } from 'vue'
|
||||
import { defineComponent, defineAsyncComponent, computed, onMounted } from 'vue'
|
||||
import { useQueryStackedNotes } from '@/hooks/useQueryStackedNotes.hook'
|
||||
import NewVersion from '@/components/NewVersion.vue'
|
||||
import Authorize from '@/components/Authorize.vue'
|
||||
import { refreshToken } from '@/modules/user/service/signIn'
|
||||
|
||||
const FluxNote = defineAsyncComponent(() => import('@/components/FluxNote.vue'))
|
||||
|
||||
@@ -33,6 +34,9 @@ export default defineComponent({
|
||||
},
|
||||
setup(props) {
|
||||
const { resetStackedNotes } = useQueryStackedNotes()
|
||||
onMounted(() => {
|
||||
refreshToken()
|
||||
})
|
||||
|
||||
return {
|
||||
resetStackedNotes,
|
||||
|
||||
Reference in New Issue
Block a user