Hello, everyone.
I am new here, but I am very interesting in NodeBB.
I want to create the new theme but I don't know how to create it.
Please teach me step by step.
Thank you for your time.
Apex
notifications.create then notifications.push not showing unread notification alert
-
I am able to get the notification alert to appear but it does not show inside the header notifications/icon.
What am i doing wrong here?
var websockets = require.main.require('./src/socket.io/'); notifications.create({ bodyShort: `Yay, this is a notification!`, pid: pid, path: '/post/' + pid, nid: 'tid:' + tid + ':uid:' + uid, tid: tid, from: 1, // 1 is my admin account }, (err, notification)=>{ console.log(notification); // this response object is OK notifications.push(notification, [uid], ()=>{ console.log('Notification created') }); });
I just want to make this notification show inside the notifications icon.
Note: When this code triggers the client user logged in does see a small alert message appear, however, the actual notification icon does not show the unread status indicator.
Do I need to set a special 'type' key on the notifications object I'm creating?
Thank you everyone for your help. Happy holidays.
-
-
@baris I am using the persona theme with my own custom theme installed . However, my custom theme is not doing any major changes to the default persona theme that are related to the unread counter.
I have added a console.log to:
// nodebb/public/src/modules/notifications.js Notifications.updateNotifCount = function (count) { console.log('updateNotifCount count:', count); // 0 ... }
The notification alert message does appear OK.
I get the following alert message "NEW NOTIFICATION" from the notification being triggered (screenshot):
However the console.log on the count object coming from the Notifications.updateNotifCount === 0
So to answer your question: The result of the console.log related to the count object is showing 0.
What should I try next?
Thank you!
-
If you are seeing
0
there the notification might already be marked read before it gets to the client side. Do you see the notification at/notifications
? If so you have to figure out why it is being marked as read. I would also try on a default persona install just to rule out any theme interference. -
One other question that maybe you or somebody else knows the answer… I have been testing and have noticed that when you create the notification if the person creating the notification has admin privileges than all the administrators also receive the notification.
So for example the user who creates the post has administrative privileges and the notification is created and pushed and that user is able to see the notification on their account however all of the other users who also have administrative privileges also receive the same notification… Is this the intended default behavior or is this potential bug?
I am trying to determine if there is some setting that I missed or if I need to write a tweak to the code to make sure that the other administrators do not see the notification that was only intended for the administrator who posted the content.
Thx!
-
I solved my own problem... I setup a custom notification to fire on the action:post.save hook and I was using the same default standard format for the notifications nid value. Basically I was firing off a notification with the same nid as the notification that auto generates when you post a new topic.
Long story short: Make sure the nid is unique.