chore: format
This commit is contained in:
parent
9a0136514b
commit
a562d9bb39
9 changed files with 37 additions and 45 deletions
|
@ -2,14 +2,10 @@ import { db } from "@/db/postgre.js";
|
|||
import { NoteEdit } from "@/models/entities/note-edit.js";
|
||||
import { awaitAll } from "@/prelude/await-all.js";
|
||||
import type { Packed } from "@/misc/schema.js";
|
||||
import {
|
||||
DriveFiles,
|
||||
} from "../index.js";
|
||||
import { DriveFiles } from "../index.js";
|
||||
|
||||
export const NoteEditRepository = db.getRepository(NoteEdit).extend({
|
||||
async pack(
|
||||
noteEdit: NoteEdit,
|
||||
) {
|
||||
async pack(noteEdit: NoteEdit) {
|
||||
const packed: Packed<"NoteEdit"> = await awaitAll({
|
||||
id: noteEdit.id,
|
||||
noteId: noteEdit.noteId,
|
||||
|
@ -18,24 +14,20 @@ export const NoteEditRepository = db.getRepository(NoteEdit).extend({
|
|||
cw: noteEdit.cw,
|
||||
fileIds: noteEdit.fileIds,
|
||||
files: DriveFiles.packMany(noteEdit.fileIds),
|
||||
})
|
||||
});
|
||||
|
||||
return packed;
|
||||
},
|
||||
async packMany(
|
||||
noteEdits: NoteEdit[],
|
||||
) {
|
||||
async packMany(noteEdits: NoteEdit[]) {
|
||||
if (noteEdits.length === 0) return [];
|
||||
|
||||
const promises = await Promise.allSettled(
|
||||
noteEdits.map((n) =>
|
||||
this.pack(n)
|
||||
),
|
||||
noteEdits.map((n) => this.pack(n)),
|
||||
);
|
||||
|
||||
// filter out rejected promises, only keep fulfilled values
|
||||
return promises.flatMap((result) =>
|
||||
result.status === "fulfilled" ? [result.value] : [],
|
||||
);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
|
@ -639,7 +639,7 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||
|
||||
(async () => {
|
||||
const noteActivity = await renderNote(note, false);
|
||||
noteActivity.updated = (new Date()).toISOString();
|
||||
noteActivity.updated = new Date().toISOString();
|
||||
const updateActivity = renderUpdate(noteActivity, user);
|
||||
updateActivity.to = noteActivity.to;
|
||||
updateActivity.cc = noteActivity.cc;
|
||||
|
|
|
@ -59,7 +59,7 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||
take: ps.limit,
|
||||
skip: ps.offset,
|
||||
order: {
|
||||
id: "DESC"
|
||||
id: "DESC",
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
@ -158,7 +158,7 @@
|
|||
>
|
||||
</div>
|
||||
<footer
|
||||
v-show="!hideFooter"
|
||||
v-show="!hideFooter"
|
||||
ref="footerEl"
|
||||
class="footer"
|
||||
tabindex="-1"
|
||||
|
|
|
@ -3,13 +3,14 @@ import type { entities } from "firefish-js";
|
|||
export function notePage(
|
||||
note: entities.Note,
|
||||
options?: {
|
||||
historyPage?: boolean
|
||||
}) {
|
||||
historyPage?: boolean;
|
||||
},
|
||||
) {
|
||||
if (options?.historyPage) {
|
||||
return `/notes/${note.id}/history`;
|
||||
}
|
||||
if (note.historyId) {
|
||||
return `/notes/${note.id}/history#${note.historyId}`
|
||||
return `/notes/${note.id}/history#${note.historyId}`;
|
||||
}
|
||||
return `/notes/${note.id}`;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
<template>
|
||||
<MkStickyContainer>
|
||||
<template #header
|
||||
><MkPageHeader
|
||||
:display-back-button="true"
|
||||
><MkPageHeader :display-back-button="true"
|
||||
/></template>
|
||||
<MkSpacer :content-max="800">
|
||||
|
||||
<MkLoading v-if="!loaded" />
|
||||
<MkPagination
|
||||
v-else
|
||||
|
@ -15,7 +13,7 @@
|
|||
>
|
||||
<div ref="tlEl" class="giivymft noGap">
|
||||
<XList
|
||||
v-slot="{item} : {item: Note}"
|
||||
v-slot="{ item }: { item: Note }"
|
||||
:items="convertNoteEditsToNotes(items)"
|
||||
class="notes"
|
||||
:no-gap="true"
|
||||
|
@ -30,15 +28,14 @@
|
|||
</XList>
|
||||
</div>
|
||||
</MkPagination>
|
||||
|
||||
</MkSpacer>
|
||||
</MkStickyContainer>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed, onMounted, ref } from "vue";
|
||||
import MkPagination from "@/components/MkPagination.vue"
|
||||
import type { Paging } from "@/components/MkPagination.vue"
|
||||
import MkPagination from "@/components/MkPagination.vue";
|
||||
import type { Paging } from "@/components/MkPagination.vue";
|
||||
import { api } from "@/os";
|
||||
import XList from "@/components/MkDateSeparatedList.vue";
|
||||
import XNote from "@/components/MkNote.vue";
|
||||
|
@ -58,7 +55,7 @@ const pagination: Paging = {
|
|||
limit: 10,
|
||||
offsetMode: true,
|
||||
params: computed(() => ({
|
||||
noteId: props.noteId
|
||||
noteId: props.noteId,
|
||||
})),
|
||||
};
|
||||
|
||||
|
@ -81,7 +78,7 @@ onMounted(() => {
|
|||
res.renoteId = null;
|
||||
res.reply = undefined;
|
||||
res.replyId = null;
|
||||
|
||||
|
||||
note.value = res;
|
||||
loaded.value = true;
|
||||
});
|
||||
|
@ -98,19 +95,21 @@ function convertNoteEditsToNotes(noteEdits: NoteEdit[]) {
|
|||
fileIds: note.value.fileIds,
|
||||
};
|
||||
|
||||
return [now].concat(noteEdits).map((noteEdit: NoteEdit, index, arr): Note => {
|
||||
return Object.assign({}, note.value, {
|
||||
historyId: noteEdit.id,
|
||||
// Conversion from updatedAt to createdAt
|
||||
// The createdAt of a edition's content is actually the updatedAt of the previous one.
|
||||
createdAt: arr[(index + 1) % arr.length].updatedAt,
|
||||
text: noteEdit.text,
|
||||
cw: noteEdit.cw,
|
||||
_shouldInsertAd_: false,
|
||||
files: noteEdit.files,
|
||||
fileIds: noteEdit.fileIds,
|
||||
return [now]
|
||||
.concat(noteEdits)
|
||||
.map((noteEdit: NoteEdit, index, arr): Note => {
|
||||
return Object.assign({}, note.value, {
|
||||
historyId: noteEdit.id,
|
||||
// Conversion from updatedAt to createdAt
|
||||
// The createdAt of a edition's content is actually the updatedAt of the previous one.
|
||||
createdAt: arr[(index + 1) % arr.length].updatedAt,
|
||||
text: noteEdit.text,
|
||||
cw: noteEdit.cw,
|
||||
_shouldInsertAd_: false,
|
||||
files: noteEdit.files,
|
||||
fileIds: noteEdit.fileIds,
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
@ -373,7 +373,7 @@ export function getNoteMenu(props: {
|
|||
: undefined,
|
||||
isEdited
|
||||
? {
|
||||
icon: `${icon('ph-clock-countdown')}`,
|
||||
icon: `${icon("ph-clock-countdown")}`,
|
||||
text: i18n.ts.noteEditHistory,
|
||||
action: () => showEditHistory(),
|
||||
}
|
||||
|
|
|
@ -664,7 +664,7 @@ export type Endpoints = {
|
|||
limit?: number;
|
||||
offset?: number;
|
||||
};
|
||||
res: NoteEdit[]
|
||||
res: NoteEdit[];
|
||||
};
|
||||
"notes/recommended-timeline": {
|
||||
req: {
|
||||
|
|
|
@ -186,7 +186,7 @@ export type NoteEdit = {
|
|||
updatedAt: string;
|
||||
fileIds: DriveFile["id"][];
|
||||
files: DriveFile[];
|
||||
}
|
||||
};
|
||||
|
||||
export type NoteReaction = {
|
||||
id: ID;
|
||||
|
|
Loading…
Reference in a new issue