chat-engine-unread-messages

Emits the $unread event on a Chat when a message event is received and the Chat is not marked as active.

Source:

require('chat-engine-unread-messages')()

Source:
Example
chat.plugin(ChatEngineCore.plugin['chat-engine-unread-messages']());

// focused on the chatroom
chat.unreadMessages.active();

// looking at any other chatroom
chat.unreadMessages.inactive();

// unread count
chat.unread;
// 4

chat.on('$unread', (payload) => {
    console.log(payload.user, "sent a message you havn't seen in ", payload.chat, "the full event is", payload.event);
});

Requires

Members

(inner) unreadCount

Augments:
Source:

(inner) unreadMessages.isActive

Augments:
Source:

Adds the property Chat.isActive to the applied Chat.

(inner) unreadMessages.unreadCount

Augments:
Source:

Adds the property Chat.unreadCount to the applied Chat.

Methods

(inner) unreadMessages.active()

Augments:
Source:

Indicate that this Chat is visible to the user. The property unreadCount is set to 0 and will not increment until inactive() is called.

(inner) unreadMessages.active()

Augments:
Source:

Indicate that the chat is in the background and unread messages should increment.

Events

$unread

Augments:
Source:
Parameters:
Name Type Description
payload Object
chat Chat

This chat

sender User

The sender of the unread message

event Object

The raw message event.