From 25763ee679dabc2a6e0b862e98357b79495e31bc Mon Sep 17 00:00:00 2001 From: GrapeApple0 <84321396+GrapeApple0@users.noreply.github.com> Date: Sat, 30 Sep 2023 05:53:12 +0000 Subject: [PATCH 01/10] =?UTF-8?q?=E3=83=8E=E3=83=BC=E3=83=88=E3=81=AE?= =?UTF-8?q?=E7=B7=A8=E9=9B=86=E5=B1=A5=E6=AD=B4=E3=82=92=E8=A6=8B=E3=82=8C?= =?UTF-8?q?=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB(=E6=96=B0=E8=A6=8F?= =?UTF-8?q?=E3=83=8E=E3=83=BC=E3=83=88=E3=81=AE=E3=81=BF)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../migration/1696044626209-noteEditHistory.js | 16 ++++++++++++++++ .../src/core/entities/NoteEntityService.ts | 1 + packages/backend/src/models/Note.ts | 7 +++++++ .../backend/src/models/json-schema/note.ts | 4 ++++ .../src/server/api/endpoints/notes/update.ts | 2 +- .../frontend/src/components/MkNoteDetailed.vue | 18 ++++++++++++++++++ 6 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 packages/backend/migration/1696044626209-noteEditHistory.js diff --git a/packages/backend/migration/1696044626209-noteEditHistory.js b/packages/backend/migration/1696044626209-noteEditHistory.js new file mode 100644 index 000000000000..37a542aa1e09 --- /dev/null +++ b/packages/backend/migration/1696044626209-noteEditHistory.js @@ -0,0 +1,16 @@ +/* + * SPDX-FileCopyrightText: syuilo and other misskey contributors + * SPDX-License-Identifier: AGPL-3.0-only + */ + +export class NoteEditHistory1696044626209 { + name = 'NoteEditHistory1696044626209' + + async up(queryRunner) { + await queryRunner.query(`ALTER TABLE "note" ADD "noteEditHistory" varchar(3000) array DEFAULT '{}'`); + } + + async down(queryRunner) { + await queryRunner.query(`ALTER TABLE "note" DROP "noteEditHistory"`); + } +} diff --git a/packages/backend/src/core/entities/NoteEntityService.ts b/packages/backend/src/core/entities/NoteEntityService.ts index a024286b4807..35dd23bbaecb 100644 --- a/packages/backend/src/core/entities/NoteEntityService.ts +++ b/packages/backend/src/core/entities/NoteEntityService.ts @@ -309,6 +309,7 @@ export class NoteEntityService implements OnModuleInit { id: note.id, createdAt: note.createdAt.toISOString(), updatedAt: note.updatedAt ? note.updatedAt.toISOString() : undefined, + noteEditHistory: note.noteEditHistory.length ? note.noteEditHistory : undefined, userId: note.userId, user: this.userEntityService.pack(note.user ?? note.userId, me, { detail: false, diff --git a/packages/backend/src/models/Note.ts b/packages/backend/src/models/Note.ts index f396a0cd7a83..ac8c4632c18f 100644 --- a/packages/backend/src/models/Note.ts +++ b/packages/backend/src/models/Note.ts @@ -29,6 +29,13 @@ export class MiNote { }) public updatedAt: Date | null; + @Column('varchar', { + length: 3000, + array: true, + default: '{}', + }) + public noteEditHistory: string[]; + @Index() @Column({ ...id(), diff --git a/packages/backend/src/models/json-schema/note.ts b/packages/backend/src/models/json-schema/note.ts index ad0cb3c45d6a..430801abf9f4 100644 --- a/packages/backend/src/models/json-schema/note.ts +++ b/packages/backend/src/models/json-schema/note.ts @@ -22,6 +22,10 @@ export const packedNoteSchema = { optional: true, nullable: true, format: 'date-time', }, + noteEditHistory: { + type: 'array', + optional: true, nullable: false, + }, deletedAt: { type: 'string', optional: true, nullable: true, diff --git a/packages/backend/src/server/api/endpoints/notes/update.ts b/packages/backend/src/server/api/endpoints/notes/update.ts index cdf7f085e0f1..4381f81975c1 100644 --- a/packages/backend/src/server/api/endpoints/notes/update.ts +++ b/packages/backend/src/server/api/endpoints/notes/update.ts @@ -73,11 +73,11 @@ export default class extends Endpoint { // eslint- if (note.userId !== me.id) { throw new ApiError(meta.errors.noSuchNote); } - await this.notesRepository.update({ id: note.id }, { updatedAt: new Date(), cw: ps.cw, text: ps.text, + noteEditHistory: [...note.noteEditHistory, note.text!], }); this.globalEventService.publishNoteStream(note.id, 'updated', { diff --git a/packages/frontend/src/components/MkNoteDetailed.vue b/packages/frontend/src/components/MkNoteDetailed.vue index ab8886e8ba9f..8afb3acb1f77 100644 --- a/packages/frontend/src/components/MkNoteDetailed.vue +++ b/packages/frontend/src/components/MkNoteDetailed.vue @@ -137,6 +137,7 @@ SPDX-License-Identifier: AGPL-3.0-only +
@@ -173,6 +174,13 @@ SPDX-License-Identifier: AGPL-3.0-only
+
+
+
+ +
+
+
@@ -192,6 +200,7 @@ import * as mfm from 'mfm-js'; import * as Misskey from 'misskey-js'; import MkNoteSub from '@/components/MkNoteSub.vue'; import MkNoteSimple from '@/components/MkNoteSimple.vue'; +import MkNotePreview from '@/components/MkNotePreview.vue'; import MkReactionsViewer from '@/components/MkReactionsViewer.vue'; import MkMediaList from '@/components/MkMediaList.vue'; import MkCwButton from '@/components/MkCwButton.vue'; @@ -747,6 +756,9 @@ function loadConversation() { padding: 16px; } +.tab_history { + padding: 16px; +} .reactionTabs { display: flex; gap: 8px; @@ -810,6 +822,12 @@ function loadConversation() { } } +.historyNote { + padding-top: 10px; + min-height: 75px; + overflow: auto; +} + .muted { padding: 8px; text-align: center; From bc4d89af3ab0cd9807927abda7b99ba42ff5d929 Mon Sep 17 00:00:00 2001 From: GrapeApple0 <84321396+GrapeApple0@users.noreply.github.com> Date: Sat, 30 Sep 2023 07:43:21 +0000 Subject: [PATCH 02/10] =?UTF-8?q?=E3=82=A2=E3=82=A4=E3=82=B3=E3=83=B3?= =?UTF-8?q?=E3=81=8C=E8=87=AA=E5=88=86=E3=81=AE=E3=81=AB=E3=81=AA=E3=81=A3?= =?UTF-8?q?=E3=81=A6=E3=81=97=E3=81=BE=E3=81=86=E3=83=90=E3=82=B0=E3=82=92?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/MkNoteDetailed.vue | 46 ++++++++++++++++--- 1 file changed, 40 insertions(+), 6 deletions(-) diff --git a/packages/frontend/src/components/MkNoteDetailed.vue b/packages/frontend/src/components/MkNoteDetailed.vue index 8afb3acb1f77..b1f3720d592f 100644 --- a/packages/frontend/src/components/MkNoteDetailed.vue +++ b/packages/frontend/src/components/MkNoteDetailed.vue @@ -176,8 +176,18 @@ SPDX-License-Identifier: AGPL-3.0-only
-
- +
+ +
+
+ +
+
+
+ +
+
+
@@ -822,10 +832,34 @@ function loadConversation() { } } -.historyNote { - padding-top: 10px; - min-height: 75px; - overflow: auto; +.historyRoot { + display: flex; + margin: 0; + padding: 10px; + overflow: clip; + font-size: 0.95em; +} + +.historyMain { + flex: 1; + min-width: 0; +} + +.historyHeader { + margin-bottom: 2px; + font-weight: bold; + width: 100%; + overflow: clip; + text-overflow: ellipsis; +} +.avatar { + flex-shrink: 0 !important; + display: block !important; + margin: 0 10px 0 0 !important; + width: 40px !important; + height: 40px !important; + border-radius: 8px !important; + pointer-events: none !important; } .muted { From 5d9d5b68192f54c8041fd07df03222e6e843dcef Mon Sep 17 00:00:00 2001 From: GrapeApple0 <84321396+GrapeApple0@users.noreply.github.com> Date: Sat, 30 Sep 2023 09:57:13 +0000 Subject: [PATCH 03/10] =?UTF-8?q?=E3=83=90=E3=82=B0=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/misskey-js/src/entities.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/misskey-js/src/entities.ts b/packages/misskey-js/src/entities.ts index e6bac2a5f46f..190792391047 100644 --- a/packages/misskey-js/src/entities.ts +++ b/packages/misskey-js/src/entities.ts @@ -178,6 +178,7 @@ export type Note = { id: ID; createdAt: DateString; updatedAt?: DateString | null; + noteEditHistory: string[]; text: string | null; cw: string | null; user: User; From a56d404b5d8a8e05d8edea4982151f327ddbd471 Mon Sep 17 00:00:00 2001 From: CyberRex Date: Sat, 30 Sep 2023 22:23:14 +0900 Subject: [PATCH 04/10] =?UTF-8?q?=E5=B7=AE=E5=88=86=E8=A1=A8=E7=A4=BA?= =?UTF-8?q?=E3=82=92=E3=81=A7=E3=81=8D=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../frontend/src/components/MkNoteDetailed.vue | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/frontend/src/components/MkNoteDetailed.vue b/packages/frontend/src/components/MkNoteDetailed.vue index b1f3720d592f..89bc226d26d8 100644 --- a/packages/frontend/src/components/MkNoteDetailed.vue +++ b/packages/frontend/src/components/MkNoteDetailed.vue @@ -176,16 +176,20 @@ SPDX-License-Identifier: AGPL-3.0-only
-
+
-
- -
+
@@ -205,7 +209,7 @@ SPDX-License-Identifier: AGPL-3.0-only