chore: lint and fmt

This commit is contained in:
Julien Calixte
2026-03-28 09:38:55 +01:00
parent 8e8706e258
commit 5f48aa5690
108 changed files with 726 additions and 680 deletions

View File

@@ -1,4 +1,4 @@
import { createSchema, createFetch } from "@better-fetch/fetch"
import { createFetch, createSchema } from "@better-fetch/fetch"
import { type } from "arktype"
export type Author = { handle: string; pds: string }
@@ -12,20 +12,20 @@ const schema = createSchema(
did: "string",
handle: "string",
pds: "string",
signing_key: "string",
signing_key: "string"
}),
query: type({
identifier: "string",
}),
},
identifier: "string"
})
}
},
{ strict: true },
{ strict: true }
)
const microcosmSlingshot = createFetch({
baseURL: "https://slingshot.microcosm.blue",
// plugins: [logger()],
schema,
schema
})
export const getAuthor = async (did: string): Promise<Author | null> => {
@@ -36,7 +36,7 @@ export const getAuthor = async (did: string): Promise<Author | null> => {
try {
const { data: author } = await microcosmSlingshot(
"/xrpc/blue.microcosm.identity.resolveMiniDoc",
{ query: { identifier: did } },
{ query: { identifier: did } }
)
if (!author) {
@@ -62,7 +62,7 @@ export const getAuthors = async (dids: Set<string>) => {
const { data: author } = await microcosmSlingshot(
"/xrpc/blue.microcosm.identity.resolveMiniDoc",
{ query: { identifier: did } },
{ query: { identifier: did } }
)
if (!author) {
@@ -72,7 +72,7 @@ export const getAuthors = async (dids: Set<string>) => {
correspondanceCache.set(did, author)
return [did, author] as [string, Author | null]
}),
})
)
return new Map(correspondance)

View File

@@ -1,6 +1,6 @@
import {
BrowserOAuthClient,
buildLoopbackClientId,
buildLoopbackClientId
} from "@atproto/oauth-client-browser"
const getClientId = () =>
@@ -14,7 +14,7 @@ export const getOAuthClient = (): Promise<BrowserOAuthClient> => {
if (!clientPromise) {
clientPromise = BrowserOAuthClient.load({
clientId: getClientId(),
handleResolver: "https://bsky.social",
handleResolver: "https://bsky.social"
})
}
return clientPromise

View File

@@ -1,6 +1,6 @@
import { data } from '@/data/data'
import { DataType } from '@/data/DataType.enum'
import { AtprotoSession } from '@/data/models/AtprotoSession'
import { data } from "@/data/data"
import { DataType } from "@/data/DataType.enum"
import { AtprotoSession } from "@/data/models/AtprotoSession"
const SESSION_ID = `${DataType.AtprotoSession}-current`
@@ -8,12 +8,15 @@ export const loadSession = (): Promise<AtprotoSession | null> => {
return data.get<DataType.AtprotoSession, AtprotoSession>(SESSION_ID)
}
export const saveSession = async (did: string, handle: string): Promise<void> => {
export const saveSession = async (
did: string,
handle: string
): Promise<void> => {
const session: AtprotoSession = {
_id: SESSION_ID,
$type: DataType.AtprotoSession,
did,
handle,
handle
}
await data.update<DataType.AtprotoSession, AtprotoSession>(session)
}

View File

@@ -3,15 +3,18 @@ export const getFollows = async (did: string): Promise<Set<string>> => {
let cursor: string | undefined
do {
const url = new URL('https://public.api.bsky.app/xrpc/app.bsky.graph.getFollows')
url.searchParams.set('actor', did)
url.searchParams.set('limit', '100')
const url = new URL(
"https://public.api.bsky.app/xrpc/app.bsky.graph.getFollows"
)
url.searchParams.set("actor", did)
url.searchParams.set("limit", "100")
if (cursor) {
url.searchParams.set('cursor', cursor)
url.searchParams.set("cursor", cursor)
}
const response = await fetch(url)
const result: { follows: { did: string }[]; cursor?: string } = await response.json()
const result: { follows: { did: string }[]; cursor?: string } =
await response.json()
for (const follow of result.follows) {
follows.add(follow.did)

View File

@@ -1,6 +1,6 @@
export const withATProtoImages = (
markdown: string,
{ pds, did }: { pds: string; did: string },
{ pds, did }: { pds: string; did: string }
): string => {
const imageLinkPattern = /!\[([^\]]*)\]\((bafkrei[a-z0-9]+)\)/g

View File

@@ -1,8 +1,8 @@
<script lang="ts" setup>
import { computed, ref } from 'vue'
import { computed, ref } from "vue"
import FlipCard from '@/modules/card/components/FlipCard.vue'
import { Repetition } from '@/modules/card/hooks/useSpacedRepetitionCards'
import FlipCard from "@/modules/card/components/FlipCard.vue"
import { Repetition } from "@/modules/card/hooks/useSpacedRepetitionCards"
const props = defineProps<{ cards: Repetition[] }>()
const emits = defineEmits<{
@@ -22,24 +22,24 @@ const sortedCards = ref(
const currentIndex = ref(0)
const goToNextCard = (success: boolean) => {
const id = sortedCards.value[currentIndex.value].repetition._id ?? ''
const id = sortedCards.value[currentIndex.value].repetition._id ?? ""
if (success) {
emits('success', id)
emits("success", id)
} else {
const failedCard = sortedCards.value.at(currentIndex.value)
if (failedCard) {
sortedCards.value.push(failedCard)
}
emits('fail', id)
emits("fail", id)
}
currentIndex.value++
}
const needsReview = () => {
const id = sortedCards.value[currentIndex.value].repetition._id ?? ''
emits('needsReview', id)
const id = sortedCards.value[currentIndex.value].repetition._id ?? ""
emits("needsReview", id)
currentIndex.value++
}
</script>

View File

@@ -1,8 +1,8 @@
import { useAsyncState } from '@vueuse/core'
import { useAsyncState } from "@vueuse/core"
import { data } from '@/data/data'
import { DataType } from '@/data/DataType.enum'
import { RepetitionCard } from '@/modules/card/models/RepetitionCard'
import { data } from "@/data/data"
import { DataType } from "@/data/DataType.enum"
import { RepetitionCard } from "@/modules/card/models/RepetitionCard"
export const useNeedReviewCards = () => {
const { state: cardsToReview, isReady } = useAsyncState(async () => {

View File

@@ -31,14 +31,14 @@ export const useSpacedRepetitionCards = () => {
(file) =>
file.path !== undefined &&
file.path.startsWith("_cards") &&
file.path.endsWith(".md"),
),
file.path.endsWith(".md")
)
)
const {
state: cards,
isReady,
execute,
execute
} = useAsyncState(
async () => {
const cards: Repetition[] = []
@@ -55,7 +55,7 @@ export const useSpacedRepetitionCards = () => {
$type: DataType.RepetitionCard,
level: 1,
repeatDate: new Date(),
needsReview: false,
needsReview: false
})
if (
@@ -77,20 +77,20 @@ export const useSpacedRepetitionCards = () => {
card: {
front: toHTML(front),
back: toHTML(back),
references: toHTML(references),
},
references: toHTML(references)
}
})
}
return cards
},
[],
{ immediate: false },
{ immediate: false }
)
const successRepetition = async (cardId: string) => {
const repetition = await data.get<DataType.RepetitionCard, RepetitionCard>(
cardId,
cardId
)
if (!repetition) {
return
@@ -100,13 +100,13 @@ export const useSpacedRepetitionCards = () => {
...repetition,
needsReview: false,
level: Math.min(repetition.level + 1, MAX_LEVEL),
repeatDate: addDays(new Date(), 2 ** repetition.level),
repeatDate: addDays(new Date(), 2 ** repetition.level)
})
}
const failRepetition = async (cardId: string) => {
const repetition = await data.get<DataType.RepetitionCard, RepetitionCard>(
cardId,
cardId
)
if (!repetition) {
return
@@ -118,13 +118,13 @@ export const useSpacedRepetitionCards = () => {
...repetition,
level,
needsReview: false,
repeatDate: addDays(new Date(), level),
repeatDate: addDays(new Date(), level)
})
}
const needsReview = async (cardId: string) => {
const repetition = await data.get<DataType.RepetitionCard, RepetitionCard>(
cardId,
cardId
)
if (!repetition) {
return
@@ -132,7 +132,7 @@ export const useSpacedRepetitionCards = () => {
await data.update<DataType.RepetitionCard, RepetitionCard>({
...repetition,
needsReview: true,
needsReview: true
})
}
@@ -142,7 +142,7 @@ export const useSpacedRepetitionCards = () => {
nextTick(() => {
listenToClick()
}),
{ immediate: true },
{ immediate: true }
)
watch(cardFiles, () => execute())
@@ -152,6 +152,6 @@ export const useSpacedRepetitionCards = () => {
successRepetition,
failRepetition,
needsReview,
isLoading: !isReady,
isLoading: !isReady
}
}

View File

@@ -1,5 +1,5 @@
import { DataType } from '@/data/DataType.enum'
import { Model } from '@/data/models/Model'
import { DataType } from "@/data/DataType.enum"
import { Model } from "@/data/models/Model"
export interface RepetitionCard extends Model<DataType.RepetitionCard> {
level: number

View File

@@ -1,5 +1,5 @@
<script lang="ts" setup>
import { useLastVisitedRepos } from '@/modules/history/hooks/useLastVisitedRepos.hook'
import { useLastVisitedRepos } from "@/modules/history/hooks/useLastVisitedRepos.hook"
const { lastVisitedRepos } = useLastVisitedRepos()
</script>

View File

@@ -1,17 +1,17 @@
import { useAsyncState } from '@vueuse/core'
import { computed } from 'vue'
import { useAsyncState } from "@vueuse/core"
import { computed } from "vue"
import { data } from '@/data/data'
import { DataType } from '@/data/DataType.enum'
import { History } from '@/data/models/History'
import { data } from "@/data/data"
import { DataType } from "@/data/DataType.enum"
import { History } from "@/data/models/History"
const HISTORY_ID = data.generateId(DataType.History, 'history')
const HISTORY_ID = data.generateId(DataType.History, "history")
export const useLastVisitedRepos = () => {
const history = useAsyncState(
() =>
data.get<DataType.History, History>(
data.generateId(DataType.History, 'history')
data.generateId(DataType.History, "history")
),
null
)

View File

@@ -1,10 +1,10 @@
import { Ref, toValue } from 'vue'
import { Ref, toValue } from "vue"
import { data } from '@/data/data'
import { DataType } from '@/data/DataType.enum'
import { History } from '@/data/models/History'
import { data } from "@/data/data"
import { DataType } from "@/data/DataType.enum"
import { History } from "@/data/models/History"
const HISTORY_ID = data.generateId(DataType.History, 'history')
const HISTORY_ID = data.generateId(DataType.History, "history")
const MAX_REPO_HISTORY = 10
export const useVisitRepo = (newRepo: {

View File

@@ -1,14 +1,14 @@
import { data } from '@/data/data'
import { DataType } from '@/data/DataType.enum'
import { Note } from '@/modules/note/models/Note'
import { useUserRepoStore } from '@/modules/repo/store/userRepo.store'
import { data } from "@/data/data"
import { DataType } from "@/data/DataType.enum"
import { Note } from "@/modules/note/models/Note"
import { useUserRepoStore } from "@/modules/repo/store/userRepo.store"
type NoteCacheResult =
| {
note: Note
from: 'sha'
from: "sha"
}
| { note: Note; from: 'path' }
| { note: Note; from: "path" }
| { note: null; from: null }
export const prepareNoteCache = (sha: string, path?: string) => {
@@ -20,7 +20,7 @@ export const prepareNoteCache = (sha: string, path?: string) => {
const note = await data.get<DataType.Note, Note>(noteId)
if (note) {
return { note, from: 'sha' }
return { note, from: "sha" }
}
if (notePath) {
@@ -33,7 +33,7 @@ export const prepareNoteCache = (sha: string, path?: string) => {
}
return {
note,
from: 'path'
from: "path"
}
}

View File

@@ -1,4 +1,5 @@
import { computed } from "vue"
import { useUserRepoStore } from "@/modules/repo/store/userRepo.store"
export const useFolderNotes = (folders: string[]) => {
@@ -8,8 +9,8 @@ export const useFolderNotes = (folders: string[]) => {
store.files.filter(
(file) =>
folders.some((folder) => file.path?.startsWith(folder)) &&
file.path?.endsWith(".md"),
),
file.path?.endsWith(".md")
)
)
const content = computed(() =>
@@ -23,10 +24,10 @@ export const useFolderNotes = (folders: string[]) => {
})`
})
.join("\n")
: "",
: ""
)
return {
content,
content
}
}

View File

@@ -6,10 +6,10 @@ export const useNotes = () => {
const store = useUserRepoStore()
const notes = computed(() =>
store.files.filter((file) => file.path?.endsWith(".md")),
store.files.filter((file) => file.path?.endsWith(".md"))
)
return {
notes,
notes
}
}

View File

@@ -1,6 +1,6 @@
import { DataType } from '@/data/DataType.enum'
import { Model } from '@/data/models/Model'
import { Backlink } from '@/modules/note/models/Backlink'
import { DataType } from "@/data/DataType.enum"
import { Model } from "@/data/models/Model"
import { Backlink } from "@/modules/note/models/Backlink"
export interface BacklinkNote extends Model<DataType.BacklinkNote> {
sha: string

View File

@@ -1,13 +1,13 @@
import { initContract } from "@ts-rest/core"
import { type } from "arktype"
import { initQueryClient } from "@ts-rest/vue-query"
import { type } from "arktype"
const PublicNoteListItem = type({
did: "string",
rkey: "string",
title: "string",
publishedAt: "string",
createdAt: "string",
createdAt: "string"
})
export type PublicNoteListItem = typeof PublicNoteListItem.infer
@@ -18,7 +18,7 @@ const PublicNote = type({
title: "string",
content: "string",
publishedAt: "string",
createdAt: "string",
createdAt: "string"
})
export type PublicNote = typeof PublicNote.infer
@@ -31,34 +31,34 @@ export const noteRouter = contract.router({
path: "/notes",
query: type({
cursor: "string | undefined",
limit: "number | undefined",
limit: "number | undefined"
}),
responses: {
200: type({
notes: PublicNoteListItem.array(),
}),
notes: PublicNoteListItem.array()
})
},
summary: "List all notes",
summary: "List all notes"
},
noteListsByDid: {
method: "GET",
path: "/:did/notes",
pathParams: type({
did: "string",
did: "string"
}),
query: type({
cursor: "string | undefined",
limit: "number | undefined",
limit: "number | undefined"
}),
responses: {
200: type({
notes: PublicNoteListItem.array(),
}),
notes: PublicNoteListItem.array()
})
},
summary: "List all notes",
},
summary: "List all notes"
}
})
export const client = initQueryClient(noteRouter, {
baseUrl: "https://api.remanso.space",
baseUrl: "https://api.remanso.space"
})

View File

@@ -1,10 +1,10 @@
import { computed, onMounted, ref } from 'vue'
import { computed, onMounted, ref } from "vue"
import { data } from '@/data/data'
import { DataType } from '@/data/DataType.enum'
import { useRepos } from '@/hooks/useRepos.hook'
import { RepoBase } from '@/modules/repo/interfaces/RepoBase'
import { FavoriteRepo } from '@/modules/repo/models/FavoriteRepo'
import { data } from "@/data/data"
import { DataType } from "@/data/DataType.enum"
import { useRepos } from "@/hooks/useRepos.hook"
import { RepoBase } from "@/modules/repo/interfaces/RepoBase"
import { FavoriteRepo } from "@/modules/repo/models/FavoriteRepo"
export const useFavoriteRepos = () => {
const { repos } = useRepos()

View File

@@ -1,8 +1,8 @@
import { computed } from 'vue'
import { computed } from "vue"
import { useRepos } from '@/hooks/useRepos.hook'
import { useFavoriteRepos } from '@/modules/repo/hooks/useFavoriteRepos.hook'
import { RepoBase } from '@/modules/repo/interfaces/RepoBase'
import { useRepos } from "@/hooks/useRepos.hook"
import { useFavoriteRepos } from "@/modules/repo/hooks/useFavoriteRepos.hook"
import { RepoBase } from "@/modules/repo/interfaces/RepoBase"
export const useRepoList = () => {
const { savedFavoriteRepos, addFavorite, removeFavorite } = useFavoriteRepos()

View File

@@ -1,5 +1,5 @@
import { DataType } from '@/data/DataType.enum'
import { Model } from '@/data/models/Model'
import { DataType } from "@/data/DataType.enum"
import { Model } from "@/data/models/Model"
export interface FavoriteRepo extends Model<DataType.FavoriteRepo> {
isFavorite: boolean

View File

@@ -1,6 +1,6 @@
import { DataType } from '@/data/DataType.enum'
import { Model } from '@/data/models/Model'
import { RepoFile } from '@/modules/repo/interfaces/RepoFile'
import { DataType } from "@/data/DataType.enum"
import { Model } from "@/data/models/Model"
import { RepoFile } from "@/modules/repo/interfaces/RepoFile"
export interface SavedRepo extends Model<DataType.SavedRepo> {
user: string

View File

@@ -1,11 +1,11 @@
import { Octokit } from '@octokit/rest'
import { Octokit } from "@octokit/rest"
import { getAccessToken } from '@/modules/user/service/signIn'
import { getAccessToken } from "@/modules/user/service/signIn"
export const getOctokit = async (): Promise<Octokit> => {
const response = await getAccessToken()
return new Octokit({
auth: response?.token ?? ''
auth: response?.token ?? ""
})
}

View File

@@ -6,7 +6,7 @@ import { getOctokit } from "@/modules/repo/services/octo"
export const getFiles = async (
owner: string,
repo: string,
repo: string
): Promise<RepoFile[]> => {
if (!owner || !repo) {
return []
@@ -15,7 +15,7 @@ export const getFiles = async (
const commits = await octokit.request("GET /repos/{owner}/{repo}/commits", {
owner,
repo,
repo
})
const lastCommit = commits.data.shift()
@@ -30,8 +30,8 @@ export const getFiles = async (
owner,
repo,
tree_sha: lastCommit.commit.tree.sha,
recursive: "true",
},
recursive: "true"
}
)
return treeResponse?.data.tree.filter((t) => t.type === "blob") ?? []
@@ -60,7 +60,7 @@ export const getMainReadme = async (owner: string, repo: string) => {
const { render } = markdownBuilder()
const { getCachedNote, saveCacheNote } = prepareNoteCache(
`${owner}-${repo}-README`,
`${owner}-${repo}-README`
)
try {
@@ -68,7 +68,7 @@ export const getMainReadme = async (owner: string, repo: string) => {
const README = await octokit.repos.getReadme({
owner,
repo,
repo
})
if (README) {
@@ -90,7 +90,7 @@ export const getMainReadme = async (owner: string, repo: string) => {
export const getUserSettingsContent = async (
user: string,
repo: string,
files: RepoFile[],
files: RepoFile[]
): Promise<Omit<UserSettings, "chosenFontFamily"> | null> => {
const configFile = files.find((file) => file.path === ".remanso.json")
@@ -110,7 +110,7 @@ export const getUserSettingsContent = async (
export const queryFileContent = async (
user: string,
repo: string,
sha: string,
sha: string
) => {
const octokit = await getOctokit()
@@ -123,8 +123,8 @@ export const queryFileContent = async (
{
owner: user,
repo: repo,
file_sha: sha,
},
file_sha: sha
}
)
return file?.data.content ?? null

View File

@@ -1,43 +1,43 @@
import { describe, expect, it } from 'vitest'
import { describe, expect, it } from "vitest"
import { resolvePath } from './resolvePath'
import { resolvePath } from "./resolvePath"
describe('resolve path service', () => {
it('set the absolute path if path to resolve is empty', () => {
expect(resolvePath('standard/README.md', '')).toEqual('standard/')
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("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", () => {
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', () => {
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')
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', () => {
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')
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')
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')
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')
resolvePath("standard/you/are/here/README.md", "./../../../other-note.md")
).toEqual("standard/other-note.md")
})
})

View File

@@ -1,15 +1,15 @@
const sanitizePath = (path: string) => {
if (path.startsWith('./')) {
return decodeURIComponent(path.replace('./', ''))
if (path.startsWith("./")) {
return decodeURIComponent(path.replace("./", ""))
}
return decodeURIComponent(path)
}
const removeNoteFilename = (pathNote: string) => {
const path = pathNote.split('/')
const path = pathNote.split("/")
path.pop()
return sanitizePath(path.join('/'))
return sanitizePath(path.join("/"))
}
export const resolvePath = (
@@ -19,11 +19,11 @@ export const resolvePath = (
let currentAbsolutePath = removeNoteFilename(currentAbsolutePathNote)
pathToResolve = sanitizePath(pathToResolve)
while (pathToResolve.startsWith('../')) {
const adjustedAbsolutePath = currentAbsolutePath.split('/')
while (pathToResolve.startsWith("../")) {
const adjustedAbsolutePath = currentAbsolutePath.split("/")
adjustedAbsolutePath.pop()
currentAbsolutePath = adjustedAbsolutePath.join('/')
pathToResolve = pathToResolve.replace('../', '')
currentAbsolutePath = adjustedAbsolutePath.join("/")
pathToResolve = pathToResolve.replace("../", "")
}
return currentAbsolutePath

View File

@@ -9,7 +9,7 @@ import {
getCachedMainReadme,
getFiles,
getMainReadme,
getUserSettingsContent,
getUserSettingsContent
} from "@/modules/repo/services/repo"
import { refreshToken } from "@/modules/user/service/signIn"
@@ -29,7 +29,7 @@ export const useUserRepoStore = defineStore("USER_REPO_STATE", {
files: [],
readme: undefined,
userSettings: undefined,
needToLogin: false,
needToLogin: false
}),
actions: {
async setUserRepo(user: string, repo: string) {
@@ -38,7 +38,7 @@ export const useUserRepoStore = defineStore("USER_REPO_STATE", {
const savedRepoId = data.generateId(DataType.SavedRepo, `${user}-${repo}`)
const cachedSavedRepo = await data.get<DataType.SavedRepo, SavedRepo>(
savedRepoId,
savedRepoId
)
if (cachedSavedRepo) {
@@ -68,14 +68,14 @@ export const useUserRepoStore = defineStore("USER_REPO_STATE", {
$type: DataType.SavedRepo,
repo,
user,
files,
files
})
this.files = files
return getUserSettingsContent(user, repo, files)
})
.then((userSettings) => {
const chosenFontFamily = userSettings?.fontFamilies?.find(
(font) => font === this.userSettings?.chosenFontFamily,
(font) => font === this.userSettings?.chosenFontFamily
)
? this.userSettings?.chosenFontFamily
: userSettings?.fontFamily
@@ -94,7 +94,7 @@ export const useUserRepoStore = defineStore("USER_REPO_STATE", {
data.update<DataType.UserSettings, UserSettings>({
...this.userSettings,
_id: userSettingsId,
_id: userSettingsId
})
})
@@ -116,7 +116,7 @@ export const useUserRepoStore = defineStore("USER_REPO_STATE", {
const savedRepoId = data.generateId(
DataType.SavedRepo,
`${this.user}-${this.repo}`,
`${this.user}-${this.repo}`
)
const newFiles = [...this.files.filter((f) => f.sha !== file.sha), file]
data.update<DataType.SavedRepo, SavedRepo>({
@@ -124,7 +124,7 @@ export const useUserRepoStore = defineStore("USER_REPO_STATE", {
$type: DataType.SavedRepo,
repo: this.repo,
user: this.user,
files: newFiles,
files: newFiles
})
this.files = newFiles
},
@@ -147,7 +147,7 @@ export const useUserRepoStore = defineStore("USER_REPO_STATE", {
const userSettingsId = `UserSetting-${this.user}-${this.repo}`
data.update<DataType.UserSettings, UserSettings>({
...this.userSettings,
_id: userSettingsId,
_id: userSettingsId
})
},
setFontSize(fontSize: string) {
@@ -159,8 +159,8 @@ export const useUserRepoStore = defineStore("USER_REPO_STATE", {
const userSettingsId = `UserSetting-${this.user}-${this.repo}`
data.update<DataType.UserSettings, UserSettings>({
...this.userSettings,
_id: userSettingsId,
_id: userSettingsId
})
},
},
}
}
})

View File

@@ -4,5 +4,5 @@ export interface GithubToken {
refresh_token: string
refresh_token_expires_in: number
scope: string
token_type: 'bearer'
token_type: "bearer"
}

View File

@@ -11,7 +11,7 @@ const AUTHENTICATION_SERVER = "https://api.remanso.space/auth/github"
const personalTokenId = "token"
export const signIn = async (
code: string,
code: string
): Promise<GithubToken | GithubTokenError> => {
const authenticationServerURL = new URL(AUTHENTICATION_SERVER)
authenticationServerURL.searchParams.set("code", code)
@@ -84,12 +84,12 @@ export const saveAccessToken = async (githubToken: GithubToken) => {
const expirationDate = addSeconds(
new Date(),
githubToken.expires_in,
githubToken.expires_in
).toISOString()
const refreshTokenExpirationDate = addSeconds(
new Date(),
githubToken.refresh_token_expires_in,
githubToken.refresh_token_expires_in
).toISOString()
const accessToken: GithubAccessToken = {
@@ -102,11 +102,11 @@ export const saveAccessToken = async (githubToken: GithubToken) => {
refreshToken: githubToken.refresh_token,
refreshTokenExpiresIn: githubToken.refresh_token_expires_in,
refreshTokenExpirationDate,
username: "",
username: ""
}
const octokit = new Octokit({
auth: accessToken?.token,
auth: accessToken?.token
})
const user = await octokit.request("GET /user")