Skip to content

Commit

Permalink
resolve #51 and #52
Browse files Browse the repository at this point in the history
  • Loading branch information
EbiseLutica authored and atsu1125 committed Nov 30, 2022
1 parent 3645a38 commit b7fc5a3
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 11 deletions.
2 changes: 2 additions & 0 deletions locales/en-US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,8 @@ common/views/components/note-menu.vue:
delete-confirm: "Are you sure you want to delete this post?"
deleteAsAdmin: "Delete as admin"
deleteAsAdmin-confirm: "Are you sure you want to delete using administrator privileges?"
undo-renote: "Undo Renote"
undo-renote-confirm: "Are you sure you want to undo this renote?"
delete-and-edit: "Delete and Edit"
delete-and-edit-confirm: "Are you sure you want to delete this note and edit it? You will lose all reactions, renotes and replies to it."
remote: "Show original note"
Expand Down
2 changes: 2 additions & 0 deletions locales/ja-JP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,8 @@ common/views/components/note-menu.vue:
delete-confirm: "この投稿を削除しますか?"
deleteAsAdmin: "管理者として削除"
deleteAsAdmin-confirm: "管理者権限を行使してこの投稿を削除しますか?"
undo-renote: "リノートを取り消す"
undo-renote-confirm: "このリノートを取り消しますか?"
delete-and-edit: "削除して編集"
delete-and-edit-confirm: "この投稿を削除してもう一度編集しますか?この投稿へのリアクション、Renote、返信も全て削除されます。"
remote: "投稿元で見る"
Expand Down
1 change: 1 addition & 0 deletions src/client/app/common/scripts/note-mixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ export default (opts: Opts = {}) => ({
const w = this.$root.new(MkNoteMenu, {
source: this.$refs.menuButton,
note: this.appearNote,
actualNote: this.note
animation: !viaKeyboard
}).$once('closed', () => {
this.openingMenu = false;
Expand Down
29 changes: 21 additions & 8 deletions src/client/app/common/scripts/note-subscriber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ export default prop => ({
}

this.connection.send('sn', data);

if (this.$_ns_isRenote) {
this.connection.send('sn', {
id: this.$_ns_note_.id,
});
}

if (withHandler) this.connection.on('noteUpdated', this.onStreamNoteUpdated);
}
},
Expand All @@ -70,6 +77,11 @@ export default prop => ({
this.connection.send('un', {
id: this.$_ns_target.id
});
if (this.$_ns_isRenote) {
this.connection.send('un', {
id: this.$_ns_note_.id,
});
}
if (withHandler) this.connection.off('noteUpdated', this.onStreamNoteUpdated);
}
},
Expand All @@ -81,7 +93,7 @@ export default prop => ({
onStreamNoteUpdated(data) {
const { type, id, body } = data;

if (id !== this.$_ns_target.id) return;
if (id !== this.$_ns_target.id && id !== this.$_ns_note_.id) return;

switch (type) {
case 'reacted': {
Expand Down Expand Up @@ -142,13 +154,14 @@ export default prop => ({
}

case 'deleted': {
Vue.set(this.$_ns_target, 'deletedAt', body.deletedAt);
Vue.set(this.$_ns_target, 'renote', null);
this.$_ns_target.text = null;
this.$_ns_target.fileIds = [];
this.$_ns_target.poll = null;
this.$_ns_target.geo = null;
this.$_ns_target.cw = null;
const target = id === this.$_ns_target.id ? this.$_ns_target : this.$_ns_note_;
Vue.set(target, 'deletedAt', body.deletedAt);
Vue.set(target, 'renote', null);
target.text = null;
target.fileIds = [];
target.poll = null;
target.geo = null;
target.cw = null;
break;
}
}
Expand Down
29 changes: 26 additions & 3 deletions src/client/app/common/views/components/note-menu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ import i18n from '../../../i18n';
import { url } from '../../../config';
import copyToClipboard from '../../../common/scripts/copy-to-clipboard';
import { faCopy, faEye, faEyeSlash } from '@fortawesome/free-regular-svg-icons';
import { faEdit } from '@fortawesome/free-solid-svg-icons';
export default Vue.extend({
i18n: i18n('common/views/components/note-menu.vue'),
props: ['note', 'source'],
props: ['note', 'source', 'actualNote'],
data() {
return {
isFavorited: false,
Expand Down Expand Up @@ -77,7 +78,7 @@ export default Vue.extend({
...(this.note.userId == this.$store.state.i.id || this.$store.state.i.isAdmin || this.$store.state.i.isModerator ? [
null,
this.note.userId == this.$store.state.i.id ? {
icon: 'undo-alt',
icon: faEdit,
text: this.$t('delete-and-edit'),
action: this.deleteAndEdit
} : undefined,
Expand All @@ -87,7 +88,13 @@ export default Vue.extend({
action: this.del
}]
: []
)]
),
...(this.actualNote && this.actualNote.renote ? [{
icon: 'undo-alt',
text: this.$t('undo-renote'),
action: this.undoRenote
}] : []),
]
.filter(x => x !== undefined);
} else {
return [{
Expand Down Expand Up @@ -202,6 +209,22 @@ export default Vue.extend({
});
},
undoRenote() {
this.$root.dialog({
type: 'warning',
text: this.$t('undo-renote-confirm'),
showCancelButton: true
}).then(({ canceled }) => {
if (canceled) return;
this.$root.api('notes/delete', {
noteId: this.actualNote.id
}).then(() => {
this.destroyDom();
});
});
}
toggleFavorite(favorite: boolean) {
this.$root.api(favorite ? 'notes/favorites/create' : 'notes/favorites/delete', {
noteId: this.note.id
Expand Down

0 comments on commit b7fc5a3

Please sign in to comment.