0
0

Observe notification read

This commit is contained in:
tamaina 2020-05-26 14:34:49 +09:00
parent 9bee9d20f7
commit 61bdf51e90
2 changed files with 18 additions and 0 deletions

View File

@ -90,9 +90,25 @@ export default Vue.extend({
getNoteSummary: (text: string) => noteSummary(text, this.$root.i18n.messages[this.$root.i18n.locale]),
followRequestDone: false,
groupInviteDone: false,
readObserver: new IntersectionObserver((entries, observer) => {
if (!entries.some(entry => entry.isIntersecting)) return;
this.$root.stream.send('readNotification', {
id: this.notification.id
});
entries.map(({ target }) => observer.unobserve(target));
}),
faIdCardAlt, faPlus, faQuoteLeft, faQuoteRight, faRetweet, faReply, faAt, faClock, faCheck, faPollH
};
},
mounted() {
if (!this.notification.isRead) this.readObserver.observe(this.$el);
},
beforeDestroy() {
if (!this.notification.isRead) this.readObserver.unobserve(this.$el);
},
methods: {
acceptFollowRequest() {
this.followRequestDone = true;

View File

@ -75,6 +75,8 @@ export default Vue.extend({
this.$root.stream.send('readNotification', {
id: notification.id
});
notification.isRead = true;
}
this.prepend(notification);