Rename method to better describe what it does

This commit is contained in:
JC Brand 2020-08-18 21:05:36 +02:00
parent 7cbb1b23b2
commit f7ef334fac
4 changed files with 9 additions and 9 deletions

View File

@ -89,7 +89,7 @@ describe("The Controlbox", function () {
.c('active', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree(); .c('active', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree();
_converse.handleMessageStanza(msg); _converse.handleMessageStanza(msg);
await u.waitUntil(() => _converse.rosterview.el.querySelectorAll(".msgs-indicator").length); await u.waitUntil(() => _converse.rosterview.el.querySelectorAll(".msgs-indicator").length);
spyOn(chatview.model, 'incrementUnreadMsgCounter').and.callThrough(); spyOn(chatview.model, 'handleUnreadMessage').and.callThrough();
await u.waitUntil(() => _converse.chatboxviews.el.querySelector('.restore-chat .message-count')?.textContent === '1'); await u.waitUntil(() => _converse.chatboxviews.el.querySelector('.restore-chat .message-count')?.textContent === '1');
expect(_converse.rosterview.el.querySelector('.msgs-indicator').textContent).toBe('1'); expect(_converse.rosterview.el.querySelector('.msgs-indicator').textContent).toBe('1');
@ -101,7 +101,7 @@ describe("The Controlbox", function () {
}).c('body').t('hello again').up() }).c('body').t('hello again').up()
.c('active', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree(); .c('active', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree();
_converse.handleMessageStanza(msg); _converse.handleMessageStanza(msg);
await u.waitUntil(() => chatview.model.incrementUnreadMsgCounter.calls.count()); await u.waitUntil(() => chatview.model.handleUnreadMessage.calls.count());
await u.waitUntil(() => _converse.chatboxviews.el.querySelector('.restore-chat .message-count')?.textContent === '2'); await u.waitUntil(() => _converse.chatboxviews.el.querySelector('.restore-chat .message-count')?.textContent === '2');
expect(_converse.rosterview.el.querySelector('.msgs-indicator').textContent).toBe('2'); expect(_converse.rosterview.el.querySelector('.msgs-indicator').textContent).toBe('2');
chatview.model.set({'minimized': false}); chatview.model.set({'minimized': false});

View File

@ -315,7 +315,7 @@ describe("A groupchat shown in the groupchats list", function () {
let indicator_el = await u.waitUntil(() => lview.el.querySelector(".msgs-indicator")); let indicator_el = await u.waitUntil(() => lview.el.querySelector(".msgs-indicator"));
expect(indicator_el.textContent).toBe('1'); expect(indicator_el.textContent).toBe('1');
spyOn(view.model, 'incrementUnreadMsgCounter').and.callThrough(); spyOn(view.model, 'handleUnreadMessage').and.callThrough();
await view.model.handleMessageStanza( await view.model.handleMessageStanza(
$msg({ $msg({
from: room_jid+'/'+nick, from: room_jid+'/'+nick,
@ -324,7 +324,7 @@ describe("A groupchat shown in the groupchats list", function () {
type: 'groupchat' type: 'groupchat'
}).c('body').t('romeo: and another thing...').tree() }).c('body').t('romeo: and another thing...').tree()
); );
await u.waitUntil(() => view.model.incrementUnreadMsgCounter.calls.count()); await u.waitUntil(() => view.model.handleUnreadMessage.calls.count());
await u.waitUntil(() => lview.el.querySelector(".msgs-indicator").textContent === '2', 1000); await u.waitUntil(() => lview.el.querySelector(".msgs-indicator").textContent === '2', 1000);
// When the chat gets maximized again, the unread indicators are removed // When the chat gets maximized again, the unread indicators are removed

View File

@ -475,7 +475,7 @@ converse.plugins.add('converse-chat', {
if (u.shouldCreateMessage(attrs)) { if (u.shouldCreateMessage(attrs)) {
const msg = this.handleCorrection(attrs) || await this.createMessage(attrs); const msg = this.handleCorrection(attrs) || await this.createMessage(attrs);
this.notifications.set({'chat_state': null}); this.notifications.set({'chat_state': null});
this.incrementUnreadMsgCounter(msg); this.handleUnreadMessage(msg);
} }
} }
}, },
@ -1154,7 +1154,7 @@ converse.plugins.add('converse-chat', {
* @private * @private
* @param {_converse.Message} message * @param {_converse.Message} message
*/ */
incrementUnreadMsgCounter (message) { handleUnreadMessage (message) {
if (!message?.get('body')) { if (!message?.get('body')) {
return return
} }

View File

@ -2014,7 +2014,7 @@ converse.plugins.add('converse-muc', {
if (u.shouldCreateGroupchatMessage(attrs)) { if (u.shouldCreateGroupchatMessage(attrs)) {
const msg = this.handleCorrection(attrs) || await this.createMessage(attrs); const msg = this.handleCorrection(attrs) || await this.createMessage(attrs);
this.removeNotification(attrs.nick, ['composing', 'paused']); this.removeNotification(attrs.nick, ['composing', 'paused']);
this.incrementUnreadMsgCounter(msg); this.handleUnreadMessage(msg);
} }
}, },
@ -2402,10 +2402,10 @@ converse.plugins.add('converse-muc', {
/* Given a newly received message, update the unread counter if necessary. /* Given a newly received message, update the unread counter if necessary.
* @private * @private
* @method _converse.ChatRoom#incrementUnreadMsgCounter * @method _converse.ChatRoom#handleUnreadMessage
* @param { XMLElement } - The <messsage> stanza * @param { XMLElement } - The <messsage> stanza
*/ */
incrementUnreadMsgCounter (message) { handleUnreadMessage (message) {
if (!message?.get('body')) { if (!message?.get('body')) {
return return
} }