making better use of the notification system
This commit is contained in:
@@ -988,7 +988,7 @@ class NotificationSystem {
|
||||
init() {
|
||||
this.bindEvents();
|
||||
this.poll();
|
||||
setInterval(() => this.poll(), 60000); // Poll every minute
|
||||
setInterval(() => this.poll(), 10000); // Poll every 10 seconds
|
||||
}
|
||||
|
||||
bindEvents() {
|
||||
@@ -1065,6 +1065,30 @@ class NotificationSystem {
|
||||
}
|
||||
|
||||
renderItem(n) {
|
||||
if (n.type === 'approve') {
|
||||
const link = `/${n.item_id}`;
|
||||
return `
|
||||
<a href="${link}" class="notif-item ${n.is_read ? '' : 'unread'}" data-id="${n.id}">
|
||||
<div>
|
||||
<strong>Your Upload has been approved</strong>
|
||||
</div>
|
||||
<small class="notif-time">${new Date(n.created_at).toLocaleString()}</small>
|
||||
</a>
|
||||
`;
|
||||
}
|
||||
|
||||
if (n.type === 'admin_pending') {
|
||||
const link = '/admin/approve';
|
||||
return `
|
||||
<a href="${link}" class="notif-item ${n.is_read ? '' : 'unread'}" data-id="${n.id}">
|
||||
<div>
|
||||
<strong>A new upload needs approval</strong>
|
||||
</div>
|
||||
<small class="notif-time">${new Date(n.created_at).toLocaleString()}</small>
|
||||
</a>
|
||||
`;
|
||||
}
|
||||
|
||||
let typeText = 'Start';
|
||||
if (n.type === 'comment_reply') typeText = 'replied to you';
|
||||
else if (n.type === 'subscription') typeText = 'commented in a thread you follow';
|
||||
|
||||
Reference in New Issue
Block a user