Update message.isEmpty() and .isNormalBubble() with recent additions

This commit is contained in:
Scott Nonnenberg 2020-07-30 17:10:54 -07:00 committed by GitHub
parent 7eb5c922a7
commit 7eabdffcd0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -131,13 +131,15 @@
isNormalBubble() { isNormalBubble() {
return ( return (
!this.isUnsupportedMessage() && !this.isCallHistory() &&
!this.isEndSession() &&
!this.isExpirationTimerUpdate() && !this.isExpirationTimerUpdate() &&
!this.isGroupUpdate() &&
!this.isKeyChange() && !this.isKeyChange() &&
!this.isMessageHistoryUnsynced() && !this.isMessageHistoryUnsynced() &&
!this.isVerifiedChange() && !this.isProfileChange() &&
!this.isGroupUpdate() && !this.isUnsupportedMessage() &&
!this.isEndSession() !this.isVerifiedChange()
); );
}, },
@ -1195,26 +1197,56 @@
} }
}, },
isEmpty() { isEmpty() {
const body = this.get('body'); // Core message types - we check for all four because they can each stand alone
const hasBody = Boolean(this.get('body'));
const hasAttachment = (this.get('attachments') || []).length > 0; const hasAttachment = (this.get('attachments') || []).length > 0;
const quote = this.get('quote'); const hasEmbeddedContact = (this.get('contact') || []).length > 0;
const hasContact = (this.get('contact') || []).length > 0; const isSticker = Boolean(this.get('sticker'));
const sticker = this.get('sticker');
const hasPreview = (this.get('preview') || []).length > 0;
const groupUpdate = this.get('group_update');
const expirationTimerUpdate = this.get('expirationTimerUpdate');
const notEmpty = Boolean( // Rendered sync messages
body || const isCallHistory = this.isCallHistory();
hasAttachment || const isGroupUpdate = this.isGroupUpdate();
quote || const isEndSession = this.isEndSession();
hasContact || const isExpirationTimerUpdate = this.isExpirationTimerUpdate();
sticker || const isVerifiedChange = this.isVerifiedChange();
hasPreview ||
groupUpdate || // Placeholder messages
expirationTimerUpdate const isUnsupportedMessage = this.isUnsupportedMessage();
); const isTapToView = this.isTapToView();
return !notEmpty;
// Errors
const hasErrors = this.hasErrors();
// Locally-generated notifications
const isKeyChange = this.isKeyChange();
const isMessageHistoryUnsynced = this.isMessageHistoryUnsynced();
const isProfileChange = this.isProfileChange();
// Note: not all of these message types go through message.handleDataMessage
const hasSomethingToDisplay =
// Core message types
hasBody ||
hasAttachment ||
hasEmbeddedContact ||
isSticker ||
// Rendered sync messages
isCallHistory ||
isGroupUpdate ||
isEndSession ||
isExpirationTimerUpdate ||
isVerifiedChange ||
// Placeholder messages
isUnsupportedMessage ||
isTapToView ||
// Errors
hasErrors ||
// Locally-generated notifications
isKeyChange ||
isMessageHistoryUnsynced ||
isProfileChange;
return !hasSomethingToDisplay;
}, },
unload() { unload() {
if (this.quotedMessage) { if (this.quotedMessage) {