未読の投稿をすべて既読にできるように
This commit is contained in:
parent
00290fbf75
commit
fb5f6fdc10
@ -169,6 +169,9 @@
|
|||||||
%i18n:@auto-watch%
|
%i18n:@auto-watch%
|
||||||
<span slot="desc">%i18n:@auto-watch-desc%</span>
|
<span slot="desc">%i18n:@auto-watch-desc%</span>
|
||||||
</ui-switch>
|
</ui-switch>
|
||||||
|
<section>
|
||||||
|
<ui-button @click="readAllUnreadNotes">%i18n:@mark-as-read-all-unread-notes%</ui-button>
|
||||||
|
</section>
|
||||||
</section>
|
</section>
|
||||||
</ui-card>
|
</ui-card>
|
||||||
|
|
||||||
@ -488,6 +491,9 @@ export default Vue.extend({
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
readAllUnreadNotes() {
|
||||||
|
(this as any).api('i/read_all_unread_notes');
|
||||||
|
},
|
||||||
customizeHome() {
|
customizeHome() {
|
||||||
this.$router.push('/i/customize-home');
|
this.$router.push('/i/customize-home');
|
||||||
this.$emit('done');
|
this.$emit('done');
|
||||||
|
36
src/server/api/endpoints/i/read_all_unread_notes.ts
Normal file
36
src/server/api/endpoints/i/read_all_unread_notes.ts
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
import User, { ILocalUser } from '../../../../models/user';
|
||||||
|
import { publishMainStream } from '../../../../stream';
|
||||||
|
import NoteUnread from '../../../../models/note-unread';
|
||||||
|
|
||||||
|
export const meta = {
|
||||||
|
desc: {
|
||||||
|
'ja-JP': '未読の投稿をすべて既読にします。'
|
||||||
|
},
|
||||||
|
|
||||||
|
requireCredential: true,
|
||||||
|
|
||||||
|
kind: 'account-write',
|
||||||
|
|
||||||
|
params: {
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export default async (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
|
||||||
|
// Remove documents
|
||||||
|
await NoteUnread.remove({
|
||||||
|
userId: user._id
|
||||||
|
});
|
||||||
|
|
||||||
|
User.update({ _id: user._id }, {
|
||||||
|
$set: {
|
||||||
|
hasUnreadMentions: false,
|
||||||
|
hasUnreadSpecifiedNotes: false
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 全て既読になったイベントを発行
|
||||||
|
publishMainStream(user._id, 'readAllUnreadMentions');
|
||||||
|
publishMainStream(user._id, 'readAllUnreadSpecifiedNotes');
|
||||||
|
|
||||||
|
res();
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user