Skip to content

Commit 7a15afa

Browse files
authored
feat(subject): Avoids setting subject if already set. (#2615)
* feat(subject): Avoids setting subject if already set. * squash: fix comments. * squash: fix comments.
1 parent 283af7a commit 7a15afa

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

modules/xmpp/ChatRoom.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1014,10 +1014,17 @@ export default class ChatRoom extends Listenable {
10141014
* @param subject
10151015
*/
10161016
setSubject(subject) {
1017+
const valueToProcess = subject ? subject.trim() : subject;
1018+
1019+
if (valueToProcess === this.subject) {
1020+
// subject already set to the new value
1021+
return;
1022+
}
1023+
10171024
const msg = $msg({ to: this.roomjid,
10181025
type: 'groupchat' });
10191026

1020-
msg.c('subject', subject);
1027+
msg.c('subject', valueToProcess);
10211028
this.connection.send(msg);
10221029
}
10231030

@@ -1201,6 +1208,7 @@ export default class ChatRoom extends Listenable {
12011208
const subjectText = subject.text();
12021209

12031210
if (subjectText || subjectText === '') {
1211+
this.subject = subjectText.trim();
12041212
this.eventEmitter.emit(XMPPEvents.SUBJECT_CHANGED, subjectText);
12051213
logger.log(`Subject is changed to ${subjectText}`);
12061214
}

0 commit comments

Comments
 (0)