Skip to content

Commit

Permalink
🔩perf: remove contentUpdate filed
Browse files Browse the repository at this point in the history
  • Loading branch information
Blinko committed Nov 14, 2024
1 parent ae52ae5 commit 684d280
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 20 deletions.
2 changes: 0 additions & 2 deletions prisma/migrations/20241114130210_0_3_5/migration.sql

This file was deleted.

1 change: 0 additions & 1 deletion prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ model notes {
accountId Int?
createdAt DateTime @default(now()) @db.Timestamptz(6)
updatedAt DateTime @updatedAt @db.Timestamptz(6)
contentUpdateAt DateTime @default(now()) @db.Timestamptz(6)
attachments attachments[]
tags tagsToNote[]
account accounts? @relation(fields: [accountId], references: [id])
Expand Down
3 changes: 2 additions & 1 deletion public/locales/de/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,5 +122,6 @@
"action": "Aktion",
"original-password": "Original-Passwort",
"import-from-memos-memos_prod-db": "Import aus Memos(memos_prod.db)",
"when-exporting-memos_prod-db-please-close-the-memos-container-to-avoid-partial-loss-of-data": "Wenn Sie memos_prod.db exportieren, schließen Sie bitte den Memos-Container, um einen teilweisen Datenverlust zu vermeiden."
"when-exporting-memos_prod-db-please-close-the-memos-container-to-avoid-partial-loss-of-data": "Wenn Sie memos_prod.db exportieren, schließen Sie bitte den Memos-Container, um einen teilweisen Datenverlust zu vermeiden.",
"go-to-share-page": "Zur Freigabeseite gehen"
}
3 changes: 2 additions & 1 deletion public/locales/es/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,5 +120,6 @@
"user-list": "Lista de usuarios",
"create-user": "Crear usuario",
"import-from-memos-memos_prod-db": "Importar de Memos(memos_prod.db)",
"when-exporting-memos_prod-db-please-close-the-memos-container-to-avoid-partial-loss-of-data": "Al exportar memos_prod.db, cierre el contenedor de memos para evitar la pérdida parcial de datos."
"when-exporting-memos_prod-db-please-close-the-memos-container-to-avoid-partial-loss-of-data": "Al exportar memos_prod.db, cierre el contenedor de memos para evitar la pérdida parcial de datos.",
"go-to-share-page": "Ir a la página para compartir"
}
3 changes: 2 additions & 1 deletion public/locales/fr/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,5 +122,6 @@
"original-password": "Mot de passe original",
"edit-user": "Modifier l'utilisateur",
"import-from-memos-memos_prod-db": "Importation de Memos(memos_prod.db)",
"when-exporting-memos_prod-db-please-close-the-memos-container-to-avoid-partial-loss-of-data": "Lors de l'exportation de memos_prod.db, veuillez fermer le conteneur memos afin d'éviter une perte partielle des données."
"when-exporting-memos_prod-db-please-close-the-memos-container-to-avoid-partial-loss-of-data": "Lors de l'exportation de memos_prod.db, veuillez fermer le conteneur memos afin d'éviter une perte partielle des données.",
"go-to-share-page": "Aller à la page de partage"
}
3 changes: 2 additions & 1 deletion public/locales/pt/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,5 +123,6 @@
"original-password": "Palavra-passe original",
"edit-user": "Editar utilizador",
"import-from-memos-memos_prod-db": "Importar de Memos(memos_prod.db)",
"when-exporting-memos_prod-db-please-close-the-memos-container-to-avoid-partial-loss-of-data": "Ao exportar memos_prod.db, feche o contentor de memos para evitar a perda parcial de dados."
"when-exporting-memos_prod-db-please-close-the-memos-container-to-avoid-partial-loss-of-data": "Ao exportar memos_prod.db, feche o contentor de memos para evitar a perda parcial de dados.",
"go-to-share-page": "Ir para a página de partilha"
}
3 changes: 2 additions & 1 deletion public/locales/zh/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,5 +122,6 @@
"original-password": "原始密码",
"edit-user": "编辑用户",
"import-from-memos-memos_prod-db": "从备忘录导入(memos_prod.db)",
"when-exporting-memos_prod-db-please-close-the-memos-container-to-avoid-partial-loss-of-data": "导出 memos_prod.db 时,请关闭备忘录容器,以免丢失部分数据。"
"when-exporting-memos_prod-db-please-close-the-memos-container-to-avoid-partial-loss-of-data": "导出 memos_prod.db 时,请关闭备忘录容器,以免丢失部分数据。",
"go-to-share-page": "转到分享页面"
}
2 changes: 1 addition & 1 deletion src/components/BlinkoCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export const BlinkoCard = observer(({ blinkoItem, isShareMode = false }: { blink
<Icon icon="tabler:share-2" width="16" height="16" className="cursor-pointer text-desc ml-2 opacity-0 group-hover/card:opacity-100 group-hover/card:translate-x-0 translate-x-1 "
onClick={async () => {
if(!blinkoItem.isShare) {
await blinko.upsertNote.call({ id: blinkoItem.id, isShare: true })
await blinko.upsertNote.call({ id: blinkoItem.id, isShare: true ,showToast: false})
}
copy(`${window.location.origin}/share/${blinkoItem.id}`)
RootStore.Get(ToastPlugin).success('Copied successfully~ Go to share!')
Expand Down
10 changes: 5 additions & 5 deletions src/pages/share/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,19 @@ const Page = observer(() => {
}, [router.isReady])

useEffect(() => {
if(!isPc) return
if (!isPc) return
const elements = document.querySelectorAll(".tilt-card");
VanillaTilt.init(elements as any, {
max: 5,
speed: 400,
max: 5,
speed: 400,
glare: true,
"max-glare": 0.5,
"max-glare": 0.5,
});
}, [store.shareNote?.value]);

return <div className='p-4 h-[100vh] w-full flex justify-center items-center bg-gradient-to-br from-rose-400 via-fuchsia-500 to-indigo-500' >
{
store.shareNote?.value &&
store.shareNote?.value &&
<div className="tilt-card bg-background max-h-[90vh] overflow-y-scroll max-w-[500px] md:max-w-[600px] rounded-lg shadow-[1px_0_25px_11px_rgba(98,0,114,0.17)]">
<BlinkoCard blinkoItem={store.shareNote?.value} isShareMode />
</div>
Expand Down
5 changes: 2 additions & 3 deletions src/server/routers/note.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export const noteRouter = router({
if (type != -1) { where.type = type }
return await prisma.notes.findMany({
where,
orderBy: [{ isTop: "desc" }, { contentUpdateAt: orderBy }, { createdAt: orderBy }],
orderBy: [{ isTop: "desc" }, { updatedAt: orderBy }],
skip: (page - 1) * size,
take: size,
include: { tags: true, attachments: true }
Expand Down Expand Up @@ -185,8 +185,7 @@ export const noteRouter = router({
...(isArchived !== null && { isArchived }),
...(isTop !== null && { isTop }),
...(isShare !== null && { isShare }),
...(content != null && { content }),
...(content != null && { contentUpdateAt: new Date() }),
...(content != null && { content })
}

if (id) {
Expand Down
6 changes: 3 additions & 3 deletions src/store/blinkoStore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ export class BlinkoStore implements Store {
updateTicker = 0
fullNoteList: Note[] = []
upsertNote = new PromiseState({
function: async ({ content = null, isArchived, type, id, attachments = [], refresh = true, isTop, isShare }:
{ content?: string | null, isArchived?: boolean, type?: NoteType, id?: number, attachments?: Attachment[], refresh?: boolean, isTop?: boolean, isShare?: boolean }) => {
function: async ({ content = null, isArchived, type, id, attachments = [], refresh = true, isTop, isShare, showToast = true }:
{ content?: string | null, isArchived?: boolean, type?: NoteType, id?: number, attachments?: Attachment[], refresh?: boolean, isTop?: boolean, isShare?: boolean, showToast?: boolean }) => {
if (type == undefined) {
type = this.noteTypeDefault
}
Expand All @@ -57,7 +57,7 @@ export class BlinkoStore implements Store {
api.ai.embeddingUpsert.mutate({ id: res!.id, content: res!.content, type: id ? 'update' : 'insert' }, { context: { skipBatch: true } })
}
eventBus.emit('editor:clear')
RootStore.Get(ToastPlugin).success(id ? i18n.t("update-successfully") : i18n.t("create-successfully"))
showToast && RootStore.Get(ToastPlugin).success(id ? i18n.t("update-successfully") : i18n.t("create-successfully"))
refresh && this.updateTicker++
return res
}
Expand Down

0 comments on commit 684d280

Please sign in to comment.