diff --git a/js/modules/loki_public_chat_api.js b/js/modules/loki_public_chat_api.js index de93b6622..110885d5c 100644 --- a/js/modules/loki_public_chat_api.js +++ b/js/modules/loki_public_chat_api.js @@ -324,17 +324,20 @@ class LokiPublicChannelAPI { // get moderator status async pollOnceForModerators() { // get moderator status - const res = await this.serverRequest(`loki/v1/channel/${this.channelId}/get_moderators`); + const res = await this.serverRequest( + `loki/v1/channel/${this.channelId}/get_moderators` + ); const ourNumber = textsecure.storage.user.getNumber(); - // if no problems and we have data - let moderators; - if (!res.err && res.response && res.response.moderators) { - moderators = res.response.moderators; + + // Get the list of moderators if no errors occurred + const moderators = !res.err && res.response && res.response.moderators; + + // if we encountered problems then we'll keep the old mod status + if (moderators) { this.modStatus = moderators.includes(ourNumber); } - // if problems, we won't drop moderator status - await this.conversation.setModerators(moderators); + await this.conversation.setModerators(moderators || []); // get token info const tokenRes = await this.serverRequest('token'); diff --git a/stylesheets/_modules.scss b/stylesheets/_modules.scss index 5c5253436..7e9cd9895 100644 --- a/stylesheets/_modules.scss +++ b/stylesheets/_modules.scss @@ -2054,16 +2054,16 @@ } .module-avatar__icon--crown-wrapper { - position: absolute; - bottom: 0; - right: 0; - height: 21px; - width: 21px; - transform: translate(25%, 25%); - padding: 9%; - background-color: $color-white; - border-radius: 50%; - filter: drop-shadow(0px 0px 4px rgba(0, 0, 0, 0.3)); + position: absolute; + bottom: 0; + right: 0; + height: 21px; + width: 21px; + transform: translate(25%, 25%); + padding: 9%; + background-color: $color-white; + border-radius: 50%; + filter: drop-shadow(0px 0px 4px rgba(0, 0, 0, 0.3)); } .module-avatar__icon--crown { diff --git a/ts/components/JazzIcon/JazzIcon.tsx b/ts/components/JazzIcon/JazzIcon.tsx index ac082c1af..c9fd2fcec 100644 --- a/ts/components/JazzIcon/JazzIcon.tsx +++ b/ts/components/JazzIcon/JazzIcon.tsx @@ -94,7 +94,11 @@ export class JazzIcon extends React.PureComponent { private hueShift(colors: Array, generator: RNG) { const amount = generator.random() * 30 - wobble / 2; - return colors.map(hex => Color(hex).rotate(amount).hex()); + return colors.map(hex => + Color(hex) + .rotate(amount) + .hex() + ); } private genShape( diff --git a/ts/components/conversation/Message.tsx b/ts/components/conversation/Message.tsx index b705ccb36..e3d4583d1 100644 --- a/ts/components/conversation/Message.tsx +++ b/ts/components/conversation/Message.tsx @@ -196,6 +196,34 @@ export class Message extends React.PureComponent { }); } + public renderMetadataBadges() { + const { direction, isP2p, isPublic, isModerator } = this.props; + + const badges = [isPublic && 'Public', isP2p && 'P2p', isModerator && 'Mod']; + + return badges + .map(badgeText => { + if (typeof badgeText !== 'string') { + return null; + } + + return ( + +  • {badgeText} + + ); + }) + .filter(i => !!i); + } + public renderMetadata() { const { collapseMetadata, @@ -207,9 +235,6 @@ export class Message extends React.PureComponent { text, textPending, timestamp, - isP2p, - isPublic, - isModerator, } = this.props; if (collapseMetadata) { @@ -220,23 +245,6 @@ export class Message extends React.PureComponent { const withImageNoCaption = Boolean(!text && isShowingImage); const showError = status === 'error' && direction === 'outgoing'; - const badges = [isPublic && 'Public', isP2p && 'P2p', isModerator && 'Mod'].map(badgeText => { - if (typeof badgeText !== 'string') return null; - return ( - -  • {badgeText} - - ) - }).filter(i => !!i); - return (
{ module="module-message__metadata__date" /> )} - {badges} + {this.renderMetadataBadges()} {expirationLength && expirationTimestamp ? (