A
A
Analka2020-02-11 22:04:52
Vue.js
Analka, 2020-02-11 22:04:52

Vuejs unread messages?

How to find out if the interlocutor has our dialogue open with him, so as not to assign the unread status to the message sent to him if he has the same dialogue open?

if (this.dialogSelect > 0){
    window.Echo.private('chat.' + this.dialogSelect)
        .listen('DialogMessage',({data,user_id}) => {
            this.messages.push({
                avatar: this.userAuth.avatar,
                fullname: this.userAuth.fullname,
                user_id: this.userAuth.id,
                replay: data
            });
            $('.contact-list__items[data-id="'+this.dialogSelect+'"]').find('.typing').removeClass('active');
            $('.chat--messages__wrapper').scrollTop($('.chat--messages__wrapper').prop('scrollHeight'));
        })
        .listenForWhisper('typing', (e) => {
            console.log(e);
            $('.contact-list__items[data-id="'+this.dialogSelect+'"]').find('.typing').addClass('active');

            if (this.typingTimer) clearTimeout(this.typingTimer);

            this.typingTimer = setTimeout(() => {
                $('.contact-list__items[data-id="'+this.dialogSelect+'"]').find('.typing').removeClass('active');
            }, 2000);
        });
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
fan92rus, 2020-02-12
@fan92rus

In any case, assign the status Not sent, Delivered, Read. here you need a server and technology to update data without a WebSocket, LongPooling request.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question