Fix #729: Display new notifications immediatly on notifications page

This commit is contained in:
Eliot Berriot 2019-03-07 11:03:45 +01:00
parent 99b8ef2d02
commit 9e6bbb4833
No known key found for this signature in database
GPG Key ID: DD6965E2476E5C27
2 changed files with 11 additions and 7 deletions

View File

@ -0,0 +1 @@
Display new notifications immediatly on notifications page (#729)

View File

@ -1,10 +1,7 @@
<template> <template>
<main class="main pusher" v-title="labels.title"> <main class="main pusher" v-title="labels.title">
<section class="ui vertical aligned stripe segment"> <section class="ui vertical aligned stripe segment">
<div v-if="isLoading" :class="['ui', {'active': isLoading}, 'inverted', 'dimmer']"> <div class="ui container">
<div class="ui text loader"><translate>Loading notifications</translate></div>
</div>
<div v-else class="ui container">
<h1 class="ui header"><translate>Your notifications</translate></h1> <h1 class="ui header"><translate>Your notifications</translate></h1>
<div class="ui toggle checkbox"> <div class="ui toggle checkbox">
<input v-model="filters.is_read" type="checkbox"> <input v-model="filters.is_read" type="checkbox">
@ -18,7 +15,12 @@
<translate>Mark all as read</translate> <translate>Mark all as read</translate>
</div> </div>
<div class="ui hidden divider" /> <div class="ui hidden divider" />
<table v-if="notifications.count > 0" class="ui table">
<div v-if="isLoading" :class="['ui', {'active': isLoading}, 'inverted', 'dimmer']">
<div class="ui text loader"><translate>Loading notifications</translate></div>
</div>
<table v-else-if="notifications.count > 0" class="ui table">
<tbody> <tbody>
<notification-row :item="item" v-for="item in notifications.results" :key="item.id" /> <notification-row :item="item" v-for="item in notifications.results" :key="item.id" />
</tbody> </tbody>
@ -42,7 +44,7 @@ export default {
data() { data() {
return { return {
isLoading: false, isLoading: false,
notifications: null, notifications: {count: 0, results: []},
filters: { filters: {
is_read: false is_read: false
} }
@ -77,6 +79,7 @@ export default {
}, },
methods: { methods: {
handleNewNotification (event) { handleNewNotification (event) {
this.notifications.count += 1
this.notifications.results.unshift(event.item) this.notifications.results.unshift(event.item)
}, },
fetch(params) { fetch(params) {