refactor (client): stop importing things directly from firefish-js/src
This commit is contained in:
parent
f70c9efe6b
commit
81b9fdf397
1 changed files with 21 additions and 19 deletions
|
@ -8,12 +8,12 @@
|
||||||
<MkPagination
|
<MkPagination
|
||||||
v-else
|
v-else
|
||||||
ref="pagingComponent"
|
ref="pagingComponent"
|
||||||
v-slot="{ items }: { items: NoteEdit[] }"
|
v-slot="{ items }: { items: entities.NoteEdit[] }"
|
||||||
:pagination="pagination"
|
:pagination="pagination"
|
||||||
>
|
>
|
||||||
<div ref="tlEl" class="giivymft noGap">
|
<div ref="tlEl" class="giivymft noGap">
|
||||||
<XList
|
<XList
|
||||||
v-slot="{ item }: { item: Note }"
|
v-slot="{ item }: { item: entities.Note }"
|
||||||
:items="convertNoteEditsToNotes(items)"
|
:items="convertNoteEditsToNotes(items)"
|
||||||
class="notes"
|
class="notes"
|
||||||
:no-gap="true"
|
:no-gap="true"
|
||||||
|
@ -42,7 +42,7 @@ import XNote from "@/components/MkNote.vue";
|
||||||
import { i18n } from "@/i18n";
|
import { i18n } from "@/i18n";
|
||||||
import { definePageMetadata } from "@/scripts/page-metadata";
|
import { definePageMetadata } from "@/scripts/page-metadata";
|
||||||
import icon from "@/scripts/icon";
|
import icon from "@/scripts/icon";
|
||||||
import type { Note, NoteEdit } from "firefish-js/src/entities";
|
import type { entities } from "firefish-js";
|
||||||
|
|
||||||
const pagingComponent = ref<InstanceType<typeof MkPagination>>();
|
const pagingComponent = ref<InstanceType<typeof MkPagination>>();
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ definePageMetadata(
|
||||||
})),
|
})),
|
||||||
);
|
);
|
||||||
|
|
||||||
const note = ref<Note>({} as Note);
|
const note = ref<entities.Note>({} as entities.Note);
|
||||||
const loaded = ref(false);
|
const loaded = ref(false);
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
@ -84,8 +84,8 @@ onMounted(() => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function convertNoteEditsToNotes(noteEdits: NoteEdit[]) {
|
function convertNoteEditsToNotes(noteEdits: entities.NoteEdit[]) {
|
||||||
const now: NoteEdit = {
|
const now: entities.NoteEdit = {
|
||||||
id: "EditionNow",
|
id: "EditionNow",
|
||||||
noteId: note.value.id,
|
noteId: note.value.id,
|
||||||
updatedAt: note.value.createdAt,
|
updatedAt: note.value.createdAt,
|
||||||
|
@ -96,20 +96,22 @@ function convertNoteEditsToNotes(noteEdits: NoteEdit[]) {
|
||||||
emojis: note.value.emojis,
|
emojis: note.value.emojis,
|
||||||
};
|
};
|
||||||
|
|
||||||
return [now].concat(noteEdits).map((noteEdit: NoteEdit, index, arr): Note => {
|
return [now]
|
||||||
return Object.assign({}, note.value, {
|
.concat(noteEdits)
|
||||||
historyId: noteEdit.id,
|
.map((noteEdit: entities.NoteEdit, index, arr): entities.Note => {
|
||||||
// Conversion from updatedAt to createdAt
|
return Object.assign({}, note.value, {
|
||||||
// The createdAt of a edition's content is actually the updatedAt of the previous one.
|
historyId: noteEdit.id,
|
||||||
createdAt: arr[(index + 1) % arr.length].updatedAt,
|
// Conversion from updatedAt to createdAt
|
||||||
text: noteEdit.text,
|
// The createdAt of a edition's content is actually the updatedAt of the previous one.
|
||||||
cw: noteEdit.cw,
|
createdAt: arr[(index + 1) % arr.length].updatedAt,
|
||||||
_shouldInsertAd_: false,
|
text: noteEdit.text,
|
||||||
files: noteEdit.files,
|
cw: noteEdit.cw,
|
||||||
fileIds: noteEdit.fileIds,
|
_shouldInsertAd_: false,
|
||||||
emojis: note.value.emojis.concat(noteEdit.emojis),
|
files: noteEdit.files,
|
||||||
|
fileIds: noteEdit.fileIds,
|
||||||
|
emojis: note.value.emojis.concat(noteEdit.emojis),
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue