Skip to content

Commit 25763ee

Browse files
committed
ノートの編集履歴を見れるように(新規ノートのみ)
1 parent 6840434 commit 25763ee

File tree

6 files changed

+47
-1
lines changed

6 files changed

+47
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* SPDX-FileCopyrightText: syuilo and other misskey contributors
3+
* SPDX-License-Identifier: AGPL-3.0-only
4+
*/
5+
6+
export class NoteEditHistory1696044626209 {
7+
name = 'NoteEditHistory1696044626209'
8+
9+
async up(queryRunner) {
10+
await queryRunner.query(`ALTER TABLE "note" ADD "noteEditHistory" varchar(3000) array DEFAULT '{}'`);
11+
}
12+
13+
async down(queryRunner) {
14+
await queryRunner.query(`ALTER TABLE "note" DROP "noteEditHistory"`);
15+
}
16+
}

packages/backend/src/core/entities/NoteEntityService.ts

+1
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ export class NoteEntityService implements OnModuleInit {
309309
id: note.id,
310310
createdAt: note.createdAt.toISOString(),
311311
updatedAt: note.updatedAt ? note.updatedAt.toISOString() : undefined,
312+
noteEditHistory: note.noteEditHistory.length ? note.noteEditHistory : undefined,
312313
userId: note.userId,
313314
user: this.userEntityService.pack(note.user ?? note.userId, me, {
314315
detail: false,

packages/backend/src/models/Note.ts

+7
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ export class MiNote {
2929
})
3030
public updatedAt: Date | null;
3131

32+
@Column('varchar', {
33+
length: 3000,
34+
array: true,
35+
default: '{}',
36+
})
37+
public noteEditHistory: string[];
38+
3239
@Index()
3340
@Column({
3441
...id(),

packages/backend/src/models/json-schema/note.ts

+4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ export const packedNoteSchema = {
2222
optional: true, nullable: true,
2323
format: 'date-time',
2424
},
25+
noteEditHistory: {
26+
type: 'array',
27+
optional: true, nullable: false,
28+
},
2529
deletedAt: {
2630
type: 'string',
2731
optional: true, nullable: true,

packages/backend/src/server/api/endpoints/notes/update.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,11 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
7373
if (note.userId !== me.id) {
7474
throw new ApiError(meta.errors.noSuchNote);
7575
}
76-
7776
await this.notesRepository.update({ id: note.id }, {
7877
updatedAt: new Date(),
7978
cw: ps.cw,
8079
text: ps.text,
80+
noteEditHistory: [...note.noteEditHistory, note.text!],
8181
});
8282

8383
this.globalEventService.publishNoteStream(note.id, 'updated', {

packages/frontend/src/components/MkNoteDetailed.vue

+18
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ SPDX-License-Identifier: AGPL-3.0-only
137137
<button class="_button" :class="[$style.tab, { [$style.tabActive]: tab === 'replies' }]" @click="tab = 'replies'"><i class="ti ti-arrow-back-up"></i> {{ i18n.ts.replies }}</button>
138138
<button class="_button" :class="[$style.tab, { [$style.tabActive]: tab === 'renotes' }]" @click="tab = 'renotes'"><i class="ti ti-repeat"></i> {{ i18n.ts.renotes }}</button>
139139
<button class="_button" :class="[$style.tab, { [$style.tabActive]: tab === 'reactions' }]" @click="tab = 'reactions'"><i class="ti ti-icons"></i> {{ i18n.ts.reactions }}</button>
140+
<button class="_button" :class="[$style.tab, { [$style.tabActive]: tab === 'history' }]" @click="tab = 'history'"><i class="ti ti-pencil"></i> {{ i18n.ts.edited }}</button>
140141
</div>
141142
<div>
142143
<div v-if="tab === 'replies'" :class="$style.tab_replies">
@@ -173,6 +174,13 @@ SPDX-License-Identifier: AGPL-3.0-only
173174
</template>
174175
</MkPagination>
175176
</div>
177+
<div v-else-if="tab === 'history'" :class="$style.tab_history">
178+
<div style="display: grid;">
179+
<div v-for="text in appearNote.noteEditHistory.reverse()" :key="text">
180+
<MkNotePreview :class="$style.historyNote" :text="text"/>
181+
</div>
182+
</div>
183+
</div>
176184
</div>
177185
</div>
178186
<div v-else class="_panel" :class="$style.muted" @click="muted = false">
@@ -192,6 +200,7 @@ import * as mfm from 'mfm-js';
192200
import * as Misskey from 'misskey-js';
193201
import MkNoteSub from '@/components/MkNoteSub.vue';
194202
import MkNoteSimple from '@/components/MkNoteSimple.vue';
203+
import MkNotePreview from '@/components/MkNotePreview.vue';
195204
import MkReactionsViewer from '@/components/MkReactionsViewer.vue';
196205
import MkMediaList from '@/components/MkMediaList.vue';
197206
import MkCwButton from '@/components/MkCwButton.vue';
@@ -747,6 +756,9 @@ function loadConversation() {
747756
padding: 16px;
748757
}
749758

759+
.tab_history {
760+
padding: 16px;
761+
}
750762
.reactionTabs {
751763
display: flex;
752764
gap: 8px;
@@ -810,6 +822,12 @@ function loadConversation() {
810822
}
811823
}
812824

825+
.historyNote {
826+
padding-top: 10px;
827+
min-height: 75px;
828+
overflow: auto;
829+
}
830+
813831
.muted {
814832
padding: 8px;
815833
text-align: center;

0 commit comments

Comments
 (0)