Skip to content

Commit

Permalink
Merge commit 'refs/pull/11938/head' of https://github.com/misskey-dev…
Browse files Browse the repository at this point in the history
…/misskey into develop
  • Loading branch information
noridev committed Sep 30, 2023
2 parents 5ec40d5 + 5d9d5b6 commit d3b552d
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 1 deletion.
16 changes: 16 additions & 0 deletions packages/backend/migration/1696044626209-noteEditHistory.js
Original file line number Diff line number Diff line change
@@ -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"`);
}
}
1 change: 1 addition & 0 deletions packages/backend/src/core/entities/NoteEntityService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,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,
Expand Down
7 changes: 7 additions & 0 deletions packages/backend/src/models/Note.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ export class MiNote {
})
public updatedAt: Date | null;

@Column('varchar', {
length: 3000,
array: true,
default: '{}',
})
public noteEditHistory: string[];

@Index()
@Column({
...id(),
Expand Down
4 changes: 4 additions & 0 deletions packages/backend/src/models/json-schema/note.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/server/api/endpoints/notes/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // 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', {
Expand Down
1 change: 1 addition & 0 deletions packages/cherrypick-js/src/entities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ export type Note = {
id: ID;
createdAt: DateString;
updatedAt?: DateString | null;
noteEditHistory: string[];
text: string | null;
cw: string | null;
user: User;
Expand Down
52 changes: 52 additions & 0 deletions packages/frontend/src/components/MkNoteDetailed.vue
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<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>
<button class="_button" :class="[$style.tab, { [$style.tabActive]: tab === 'renotes' }]" @click="tab = 'renotes'"><i class="ti ti-repeat"></i> {{ i18n.ts.renotes }}</button>
<button class="_button" :class="[$style.tab, { [$style.tabActive]: tab === 'reactions' }]" @click="tab = 'reactions'"><i class="ti ti-icons"></i> {{ i18n.ts.reactions }}</button>
<button class="_button" :class="[$style.tab, { [$style.tabActive]: tab === 'history' }]" @click="tab = 'history'"><i class="ti ti-pencil"></i> {{ i18n.ts.edited }}</button>
</div>
<div>
<div v-if="tab === 'replies'" :class="$style.tab_replies">
Expand Down Expand Up @@ -213,6 +214,23 @@ SPDX-License-Identifier: AGPL-3.0-only
</template>
</MkPagination>
</div>
<div v-else-if="tab === 'history'" :class="$style.tab_history">
<div style="display: grid;">
<div v-for="text in appearNote.noteEditHistory" :class="$style.historyRoot" :key="text">
<MkAvatar :class="$style.avatar" :user="appearNote.user" link preview/>
<div :class="$style.historyMain">
<div :class="$style.historyHeader">
<MkUserName :user="appearNote.user" :nowrap="true"/>
</div>
<div>
<div>
<Mfm :text="text.trim()" :author="appearNote.user" :i="$i"/>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div v-else class="_panel" :class="$style.muted" @click="muted = false">
Expand All @@ -232,6 +250,7 @@ import * as mfm from 'cherrypick-mfm-js';
import * as Misskey from 'cherrypick-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';
Expand Down Expand Up @@ -954,6 +973,9 @@ onMounted(() => {
padding: 16px;
}

.tab_history {
padding: 16px;
}
.reactionTabs {
display: flex;
gap: 8px;
Expand Down Expand Up @@ -1018,6 +1040,36 @@ onMounted(() => {
}
}

.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 {
padding: 8px;
text-align: center;
Expand Down

0 comments on commit d3b552d

Please sign in to comment.