diff --git a/app/containers/message/Thread.js b/app/containers/message/Thread.js
index a3f6cff1e..320bb3cc3 100644
--- a/app/containers/message/Thread.js
+++ b/app/containers/message/Thread.js
@@ -19,11 +19,10 @@ const Thread = React.memo(({
}
const {
- getBadgeColor, toggleFollowThread, user, replies
+ threadBadgeColor, toggleFollowThread, user, replies
} = useContext(MessageContext);
const time = formatDateThreads(tlm);
const buttonText = formatMessageCount(tcount, THREAD);
- const badgeColor = getBadgeColor?.(id);
const isFollowing = replies?.find(u => u === user.id);
return (
@@ -35,7 +34,7 @@ const Thread = React.memo(({
{buttonText}
{time}
- {badgeColor ? : null}
+ {threadBadgeColor ? : null}
toggleFollowThread(isFollowing, id)}>
- {parentTitle}
+ {parentTitle}
);
}
diff --git a/app/views/RoomView/List.js b/app/views/RoomView/List.js
index 0008153ae..d0d3aa39a 100644
--- a/app/views/RoomView/List.js
+++ b/app/views/RoomView/List.js
@@ -30,6 +30,7 @@ class List extends React.Component {
loading: PropTypes.bool,
listRef: PropTypes.func,
hideSystemMessages: PropTypes.array,
+ tunread: PropTypes.array,
navigation: PropTypes.object,
showMessageInMainThread: PropTypes.bool
};
@@ -76,7 +77,7 @@ class List extends React.Component {
shouldComponentUpdate(nextProps, nextState) {
const { loading, end, refreshing } = this.state;
- const { hideSystemMessages, theme } = this.props;
+ const { hideSystemMessages, theme, tunread } = this.props;
if (theme !== nextProps.theme) {
return true;
}
@@ -92,6 +93,9 @@ class List extends React.Component {
if (!isEqual(hideSystemMessages, nextProps.hideSystemMessages)) {
return true;
}
+ if (!isEqual(tunread, nextProps.tunread)) {
+ return true;
+ }
return false;
}
diff --git a/app/views/RoomView/index.js b/app/views/RoomView/index.js
index db722e690..b9d185994 100644
--- a/app/views/RoomView/index.js
+++ b/app/views/RoomView/index.js
@@ -73,7 +73,7 @@ const stateAttrsUpdate = [
'readOnly',
'member'
];
-const roomAttrsUpdate = ['f', 'ro', 'blocked', 'blocker', 'archived', 'muted', 'jitsiTimeout', 'announcement', 'sysMes', 'topic', 'name', 'fname', 'roles', 'bannerClosed', 'visitor'];
+const roomAttrsUpdate = ['f', 'ro', 'blocked', 'blocker', 'archived', 'muted', 'tunread', 'jitsiTimeout', 'announcement', 'sysMes', 'topic', 'name', 'fname', 'roles', 'bannerClosed', 'visitor'];
class RoomView extends React.Component {
static propTypes = {
@@ -909,7 +909,7 @@ class RoomView extends React.Component {
getCustomEmoji={this.getCustomEmoji}
callJitsi={this.callJitsi}
blockAction={this.blockAction}
- getBadgeColor={this.getBadgeColor}
+ threadBadgeColor={this.getBadgeColor(item?.id)}
toggleFollowThread={this.toggleFollowThread}
/>
);
@@ -1053,7 +1053,7 @@ class RoomView extends React.Component {
t={t}
tmid={this.tmid}
theme={theme}
- room={room}
+ tunread={room?.tunread}
renderRow={this.renderItem}
loading={loading}
navigation={navigation}
diff --git a/app/views/RoomsListView/index.js b/app/views/RoomsListView/index.js
index 8ed44e123..ed4226872 100644
--- a/app/views/RoomsListView/index.js
+++ b/app/views/RoomsListView/index.js
@@ -157,7 +157,7 @@ class RoomsListView extends React.Component {
searching: false,
search: [],
loading: true,
- chatsOrder: [],
+ chatsUpdate: [],
chats: [],
item: {}
};
@@ -224,7 +224,7 @@ class RoomsListView extends React.Component {
}
shouldComponentUpdate(nextProps, nextState) {
- const { chatsOrder, searching, item } = this.state;
+ const { chatsUpdate, searching, item } = this.state;
// eslint-disable-next-line react/destructuring-assignment
const propsUpdated = shouldUpdateProps.some(key => nextProps[key] !== this.props[key]);
if (propsUpdated) {
@@ -232,7 +232,7 @@ class RoomsListView extends React.Component {
}
// Compare changes only once
- const chatsNotEqual = !isEqual(nextState.chatsOrder, chatsOrder);
+ const chatsNotEqual = !isEqual(nextState.chatsUpdate, chatsUpdate);
// If they aren't equal, set to update if focused
if (chatsNotEqual) {
@@ -437,7 +437,7 @@ class RoomsListView extends React.Component {
observable = await db.collections
.get('subscriptions')
.query(...defaultWhereClause)
- .observe();
+ .observeWithColumns(['alert']);
// When we're NOT grouping
} else {
@@ -456,11 +456,20 @@ class RoomsListView extends React.Component {
let tempChats = [];
let chats = data;
- /**
- * We trigger re-render only when chats order changes
- * RoomItem handles its own re-render
- */
- const chatsOrder = data.map(item => item.rid);
+ let chatsUpdate = [];
+ if (showUnread) {
+ /**
+ * If unread on top, we trigger re-render based on order changes and sub.alert
+ * RoomItem handles its own re-render
+ */
+ chatsUpdate = data.map(item => ({ rid: item.rid, alert: item.alert }));
+ } else {
+ /**
+ * Otherwise, we trigger re-render only when chats order changes
+ * RoomItem handles its own re-render
+ */
+ chatsUpdate = data.map(item => item.rid);
+ }
const isOmnichannelAgent = user?.roles?.includes('livechat-agent');
if (isOmnichannelAgent) {
@@ -501,7 +510,7 @@ class RoomsListView extends React.Component {
this.internalSetState({
chats: tempChats,
- chatsOrder,
+ chatsUpdate,
loading: false
});
});
diff --git a/storybook/stories/index.js b/storybook/stories/index.js
index 2865f5b5e..d95466c25 100644
--- a/storybook/stories/index.js
+++ b/storybook/stories/index.js
@@ -64,7 +64,7 @@ const messageDecorator = story => (
onReactionPress: () => {},
onDiscussionPress: () => {},
onReactionLongPress: () => {},
- getBadgeColor: () => themes.light.tunreadBackground
+ threadBadgeColor: themes.light.tunreadBackground
}}
>
{story()}