mirror of
https://iceshrimp.dev/limepotato/jormungandr-bite.git
synced 2024-11-23 02:17:40 -07:00
capture readAllNotifications
This commit is contained in:
parent
4a90d7cdf8
commit
9fbf046957
1 changed files with 8 additions and 1 deletions
|
@ -90,6 +90,7 @@ export default Vue.extend({
|
||||||
getNoteSummary: (text: string) => noteSummary(text, this.$root.i18n.messages[this.$root.i18n.locale]),
|
getNoteSummary: (text: string) => noteSummary(text, this.$root.i18n.messages[this.$root.i18n.locale]),
|
||||||
followRequestDone: false,
|
followRequestDone: false,
|
||||||
groupInviteDone: false,
|
groupInviteDone: false,
|
||||||
|
connection: null,
|
||||||
readObserver: new IntersectionObserver((entries, observer) => {
|
readObserver: new IntersectionObserver((entries, observer) => {
|
||||||
if (!entries.some(entry => entry.isIntersecting)) return;
|
if (!entries.some(entry => entry.isIntersecting)) return;
|
||||||
this.$root.stream.send('readNotification', {
|
this.$root.stream.send('readNotification', {
|
||||||
|
@ -102,11 +103,17 @@ export default Vue.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
if (!this.notification.isRead) this.readObserver.observe(this.$el);
|
if (!this.notification.isRead) {
|
||||||
|
this.readObserver.observe(this.$el);
|
||||||
|
|
||||||
|
this.connection = this.$root.stream.useSharedConnection('main');
|
||||||
|
this.connection.on('readAllNotifications', () => this.readObserver.unobserve(this.$el));
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
if (!this.notification.isRead) this.readObserver.unobserve(this.$el);
|
if (!this.notification.isRead) this.readObserver.unobserve(this.$el);
|
||||||
|
this.connection.dispose();
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
|
Loading…
Reference in a new issue