diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2018-10-19 06:36:59 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2018-10-19 06:36:59 +0900 |
| commit | fb5f6fdc103e83652415a3f1379a01f1fb487585 (patch) | |
| tree | a95a963c5f53aeda43516b5821a6cd44f7edd6db /src | |
| parent | Fix bug (diff) | |
| download | sharkey-fb5f6fdc103e83652415a3f1379a01f1fb487585.tar.gz sharkey-fb5f6fdc103e83652415a3f1379a01f1fb487585.tar.bz2 sharkey-fb5f6fdc103e83652415a3f1379a01f1fb487585.zip | |
未読の投稿をすべて既読にできるように
Diffstat (limited to 'src')
| -rw-r--r-- | src/client/app/desktop/views/components/settings.vue | 6 | ||||
| -rw-r--r-- | src/server/api/endpoints/i/read_all_unread_notes.ts | 36 |
2 files changed, 42 insertions, 0 deletions
diff --git a/src/client/app/desktop/views/components/settings.vue b/src/client/app/desktop/views/components/settings.vue index 1a8cb6b0b9..50582b3525 100644 --- a/src/client/app/desktop/views/components/settings.vue +++ b/src/client/app/desktop/views/components/settings.vue @@ -169,6 +169,9 @@ %i18n:@auto-watch% <span slot="desc">%i18n:@auto-watch-desc%</span> </ui-switch> + <section> + <ui-button @click="readAllUnreadNotes">%i18n:@mark-as-read-all-unread-notes%</ui-button> + </section> </section> </ui-card> @@ -488,6 +491,9 @@ export default Vue.extend({ }); }, methods: { + readAllUnreadNotes() { + (this as any).api('i/read_all_unread_notes'); + }, customizeHome() { this.$router.push('/i/customize-home'); this.$emit('done'); diff --git a/src/server/api/endpoints/i/read_all_unread_notes.ts b/src/server/api/endpoints/i/read_all_unread_notes.ts new file mode 100644 index 0000000000..fae98b9816 --- /dev/null +++ b/src/server/api/endpoints/i/read_all_unread_notes.ts @@ -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(); +}); |