Skip to content

Commit

Permalink
簡易編集 (#4716)
Browse files Browse the repository at this point in the history
* edit2

* a

* Vue hash

* updatedAt

* updates

* Edit mark

* a

* m

* od

* .

* .

* ma

* deliver

* a

* recv

* l

* Revert "l"

This reverts commit 407bb84.

* a

* comment
  • Loading branch information
mei23 authored Sep 29, 2023
1 parent 343e0fe commit 68917e6
Show file tree
Hide file tree
Showing 18 changed files with 299 additions and 38 deletions.
3 changes: 3 additions & 0 deletions locales/en-US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ common:
mobile-mode: 'Mobile mode'
empty: 'Empty'
edit: 'Edit'
edit2: 'Quick edit'
edited: 'Edited'
aboutInstance: "About this instance"
favoriteReactions: "Favorite reactions"
mostReacteds: "Most reacteds"
Expand Down Expand Up @@ -660,6 +662,7 @@ common/views/components/note-menu.vue:
deleteDriveYes: "Delete drive files too"
edit: "Edit"
edit-confirm: "Are you sure you want to edit this post? Old post will be deleted."
edit2-confirm: "Quick edit leaves a history. if you don't want to keep it, use normal editing. Do you want to quick edit?"
remote: "Show original note"
report: "Report"
report-abuse-detail: "What kind of nuisance did you encounter?"
Expand Down
3 changes: 3 additions & 0 deletions locales/ja-JP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ common:
mobile-mode: 'モバイル版'
empty: 'ありません!'
edit: '編集'
edit2: '簡易編集'
edited: '編集済み'
aboutInstance: "このインスタンスについて"
favoriteReactions: "よくするリアクション"
mostReacteds: "よくされるリアクション"
Expand Down Expand Up @@ -702,6 +704,7 @@ common/views/components/note-menu.vue:
deleteDriveYes: "ドライブのファイルも削除する"
edit: "編集"
edit-confirm: "この投稿を編集しますか?古い投稿は削除されます。"
edit2-confirm: "簡易編集は履歴が残ります、残したくない場合は普通の編集を使用してください。簡易編集をしますか?"
remote: "投稿元で見る"
pin-limit-exceeded: "これ以上ピン留めできません。"
report: "通報"
Expand Down
7 changes: 7 additions & 0 deletions src/client/app/common/scripts/note-subscriber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,13 @@ export default prop => ({
this.$_ns_target.cw = null;
break;
}

case 'updated': {
Vue.set(this.$_ns_target, 'updatedAt', body.updatedAt);
Vue.set(this.$_ns_target, 'text', body.text);
Vue.set(this.$_ns_target, 'cw', body.cw);
break;
}
}

this.$emit(`update:${prop}`, this.$_ns_note_);
Expand Down
10 changes: 8 additions & 2 deletions src/client/app/common/scripts/post-form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@ export default (opts) => ({
type: Boolean,
required: false,
default: false
}
},
updateMode: {
type: Boolean,
required: false,
default: false
},
},

data() {
Expand Down Expand Up @@ -482,7 +487,7 @@ export default (opts) => ({
text = `${text.replace(/\s+$/, '')}\n#${this.fixedTag}`;
}

this.$root.api('notes/create', {
this.$root.api(this.updateMode ? 'notes/update' : 'notes/create', {
text,
fileIds: this.files.length > 0 ? this.files.map(f => f.id) : undefined,
replyId: this.reply ? this.reply.id : undefined,
Expand All @@ -494,6 +499,7 @@ export default (opts) => ({
localOnly,
copyOnce,
viaMobile,
noteId: this.updateMode ? this.initialNote?.id : undefined,
geo: null
}).then(data => {
if (this.initialNote && this.initialNote._edit) {
Expand Down
10 changes: 5 additions & 5 deletions src/client/app/common/views/components/note-header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
<span class="username"><mk-acct :user="note.user"/></span>
<x-user-badges :user="note.user" :key="note.user.id"/>
<div class="info" v-if="!noInfo">
<span class="mobile" v-if="note.viaMobile"><fa icon="mobile-alt"/></span>
<router-link v-if="noteUrl.startsWith('/')" class="created-at" :to="noteUrl"><mk-time :time="note.createdAt"/></router-link>
<a v-else class="created-at" :href="noteUrl"><mk-time :time="note.createdAt"/></a>
<span class="edited" :title="$t('@.edited')" v-if="note.updatedAt != null"><fa :icon="faEdit"/></span>
<x-visibility-icon class="visibility" :v="note.visibility" :localOnly="note.localOnly" :copyOnce="note.copyOnce"/>
<span class="remote" title="Remote post" v-if="note.user.host != null"><fa :icon="faGlobeAmericas"/></span>
</div>
Expand All @@ -18,7 +18,7 @@
<script lang="ts">
import Vue from 'vue';
import i18n from '../../../i18n';
import { faGlobeAmericas } from '@fortawesome/free-solid-svg-icons';
import { faGlobeAmericas, faEdit } from '@fortawesome/free-solid-svg-icons';
import XVisibilityIcon from '../../../common/views/components/visibility-icon.vue';
import XUserBadges from '../../../common/views/components/user-badges.vue';
import getAcct from '../../../../../misc/acct/render';
Expand All @@ -31,7 +31,7 @@ export default Vue.extend({
},
data() {
return {
faGlobeAmericas,
faGlobeAmericas, faEdit,
}
},
props: {
Expand Down Expand Up @@ -102,8 +102,8 @@ export default Vue.extend({
> *
color var(--noteHeaderInfo)
> .mobile
margin-right 8px
> .edited
margin-left 8px
> .visibility
margin-left 0.5em
Expand Down
22 changes: 22 additions & 0 deletions src/client/app/common/views/components/note-menu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Vue from 'vue';
import i18n from '../../../i18n';
import { url } from '../../../config';
import copyToClipboard from '../../../common/scripts/copy-to-clipboard';
import { faEdit } from '@fortawesome/free-solid-svg-icons';
import { faCopy } from '@fortawesome/free-regular-svg-icons';
import { faPlaneArrival, faPlaneDeparture, faUserFriends, faPaperPlane, faExclamationCircle } from '@fortawesome/free-solid-svg-icons';
Expand Down Expand Up @@ -117,6 +118,12 @@ export default Vue.extend({
text: this.$t('@.edit'),
action: this.edit
});
it.push({
icon: faEdit,
text: this.$t('@.edit2'),
action: this.edit2
});
}
// 削除
Expand Down Expand Up @@ -255,6 +262,21 @@ export default Vue.extend({
});
},
edit2() {
this.$root.dialog({
type: 'warning',
text: this.$t('edit2-confirm'),
showCancelButton: true
}).then(({ canceled }) => {
if (canceled) return;
this.$post({
initialNote: Object.assign({ }, this.note),
reply: this.note.reply,
updateMode: true,
});
});
},
toggleFavorite(favorite: boolean) {
this.$root.api(favorite ? 'notes/favorites/create' : 'notes/favorites/delete', {
noteId: this.note.id
Expand Down
2 changes: 1 addition & 1 deletion src/client/app/common/views/deck/deck.notes.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
:note="note"
:next="_notes[i + 1]"
:prev="_notes[i - 1]"
:key="note.id"
:key="`${note.id}-${note.updatedAt}`"
@update:note="onNoteUpdated(i, $event)"
:compact="true"
/>
Expand Down
1 change: 1 addition & 0 deletions src/client/app/desktop/script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ init(async (launch, os) => {
animation: o.animation == null ? true : o.animation,
initialText: o.initialText,
instant: o.instant,
updateMode: o.updateMode,
initialNote: o.initialNote
});
if (o.cb) vm.$once('closed', o.cb);
Expand Down
8 changes: 7 additions & 1 deletion src/client/app/desktop/views/components/note-detail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@
{{ }}
<mk-time :time="appearNote.createdAt" mode="detail"/>
</router-link>
<div class="time" v-if="appearNote.updatedAt != null">
<fa :icon="faEdit"/>
{{ }}
<mk-time :time="appearNote.updatedAt" mode="detail"/>
</div>
<div class="visibility-info">
<x-visibility-icon class="visibility" :v="appearNote.visibility" :localOnly="appearNote.localOnly" :copyOnce="appearNote.copyOnce" :withText="true"/>
</div>
Expand Down Expand Up @@ -108,6 +113,7 @@ import XSub from './note.sub.vue';
import noteSubscriber from '../../../common/scripts/note-subscriber';
import noteMixin from '../../../common/scripts/note-mixin';
import { faClock, faLaugh } from '@fortawesome/free-regular-svg-icons';
import { faEdit } from '@fortawesome/free-solid-svg-icons';
import XVisibilityIcon from '../../../common/views/components/visibility-icon.vue';
import XInstanceInfo from '../../../common/views/components/instance-info.vue';
Expand All @@ -134,7 +140,7 @@ export default Vue.extend({
data() {
return {
faClock, faLaugh,
faClock, faLaugh, faEdit,
conversation: [],
conversationFetching: false,
replies: []
Expand Down
8 changes: 7 additions & 1 deletion src/client/app/desktop/views/components/note.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@
{{ }}
<mk-time :time="appearNote.createdAt" mode="detail"/>
</router-link>
<div v-if="detail && appearNote.updatedAt != null" class="time">
<fa :icon="faEdit"/>
{{ }}
<mk-time :time="appearNote.updatedAt" mode="detail"/>
</div>
<div v-if="detail" class="visibility-info">
<x-visibility-icon class="visibility" :v="appearNote.visibility" :localOnly="appearNote.localOnly" :copyOnce="appearNote.copyOnce" :withText="true"/>
</div>
Expand Down Expand Up @@ -122,6 +127,7 @@ import XSub from './note.sub.vue';
import noteMixin from '../../../common/scripts/note-mixin';
import noteSubscriber from '../../../common/scripts/note-subscriber';
import { faClock, faLaugh } from '@fortawesome/free-regular-svg-icons';
import { faEdit } from '@fortawesome/free-solid-svg-icons';
import XInstanceInfo from '../../../common/views/components/instance-info.vue';
import XVisibilityIcon from '../../../common/views/components/visibility-icon.vue';
Expand Down Expand Up @@ -182,7 +188,7 @@ export default Vue.extend({
data() {
return {
faClock, faLaugh,
faClock, faLaugh, faEdit,
conversation: [],
replies: []
};
Expand Down
2 changes: 1 addition & 1 deletion src/client/app/desktop/views/components/notes.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<!-- トランジションを有効にするとなぜかメモリリークする -->
<component :is="!$store.state.device.reduceMotion ? 'transition-group' : 'div'" name="mk-notes" class="notes transition" tag="div" ref="notes">
<template v-for="(note, i) in _notes">
<mk-note :note="note" :next="_notes[i + 1]" :prev="_notes[i - 1]" :key="note.id" @update:note="onNoteUpdated(i, $event)" :compact="true" ref="note"/>
<mk-note :note="note" :next="_notes[i + 1]" :prev="_notes[i - 1]" :key="`${note.id}-${note.updatedAt}`" @update:note="onNoteUpdated(i, $event)" :compact="true" ref="note"/>
</template>
</component>

Expand Down
7 changes: 7 additions & 0 deletions src/client/app/desktop/views/components/post-form-window.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
:mention="mention"
:initial-text="initialText"
:initial-note="initialNote"
:update-mode="updateMode"
:instant="instant"

@posted="onPosted"
Expand Down Expand Up @@ -65,6 +66,12 @@ export default Vue.extend({
required: false
},
updateMode: {
type: Boolean,
required: false,
default: false
},
instant: {
type: Boolean,
required: false,
Expand Down
8 changes: 7 additions & 1 deletion src/client/app/mobile/views/components/note-detail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@
{{ }}
<mk-time :time="appearNote.createdAt" mode="detail"/>
</router-link>
<div class="time" v-if="appearNote.updatedAt != null">
<fa :icon="faEdit"/>
{{ }}
<mk-time :time="appearNote.updatedAt" mode="detail"/>
</div>
<div class="visibility-info">
<x-visibility-icon class="visibility" :v="appearNote.visibility" :localOnly="appearNote.localOnly" :copyOnce="appearNote.copyOnce" :withText="true"/>
</div>
Expand Down Expand Up @@ -107,6 +112,7 @@ import XSub from './note.sub.vue';
import noteSubscriber from '../../../common/scripts/note-subscriber';
import noteMixin from '../../../common/scripts/note-mixin';
import { faClock, faLaugh } from '@fortawesome/free-regular-svg-icons';
import { faEdit } from '@fortawesome/free-solid-svg-icons';
import XVisibilityIcon from '../../../common/views/components/visibility-icon.vue';
import XInstanceInfo from '../../../common/views/components/instance-info.vue';
Expand All @@ -133,7 +139,7 @@ export default Vue.extend({
data() {
return {
faClock, faLaugh,
faClock, faLaugh, faEdit,
conversation: [],
conversationFetching: false,
replies: []
Expand Down
2 changes: 1 addition & 1 deletion src/client/app/mobile/views/components/notes.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<!-- トランジションを有効にするとなぜかメモリリークする -->
<component :is="!$store.state.device.reduceMotion ? 'transition-group' : 'div'" name="mk-notes" class="transition" tag="div">
<template v-for="(note, i) in _notes">
<mk-note :note="note" :next="_notes[i + 1]" :prev="_notes[i - 1]" :key="note.id" @update:note="onNoteUpdated(i, $event)"/>
<mk-note :note="note" :next="_notes[i + 1]" :prev="_notes[i - 1]" :key="`${note.id}-${note.updatedAt}`" @update:note="onNoteUpdated(i, $event)"/>
</template>
</component>

Expand Down
5 changes: 4 additions & 1 deletion src/remote/activitypub/kernel/update/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { IRemoteUser } from '../../../../models/user';
import { IUpdate, isActor, getApType } from '../../type';
import { IUpdate, isActor, getApType, isPost } from '../../type';
import { apLogger } from '../../logger';
import { updateQuestion } from '../../models/question';
import Resolver from '../../resolver';
import { updatePerson } from '../../models/person';
import updateNote from './note';

/**
* Updateアクティビティを捌きます
Expand All @@ -28,6 +29,8 @@ export default async (actor: IRemoteUser, activity: IUpdate): Promise<string> =>
} else if (getApType(object) === 'Question') { // isQuestionだとNoteを含んでいる
await updateQuestion(object, resolver).catch(e => console.log(e));
return `ok: Question updated`;
} else if (isPost(object)) {
return await updateNote(actor, object);
} else {
return `skip: Unknown type: ${getApType(object)}`;
}
Expand Down
Loading

0 comments on commit 68917e6

Please sign in to comment.