Compare commits

...

4 Commits

Author SHA1 Message Date
Reinaldo Neto 180e877fcf
Merge branch 'develop' into fix.unread-section-not-change-when-read 2021-07-27 11:53:01 -03:00
Reinaldo Neto 702ffb9e58
Merge branch 'develop' into fix.unread-section-not-change-when-read 2021-07-22 13:46:28 -03:00
Reinaldo Neto aa63357231 Minor tweak 2021-07-16 16:15:27 -03:00
Reinaldo Neto 7ca2c3cfee Fix unread section from direct messages and thread messages 2021-07-16 15:30:27 -03:00
3 changed files with 31 additions and 4 deletions

View File

@ -59,6 +59,7 @@ const RoomItem = ({
toggleFav={toggleFav}
isRead={isRead}
rid={rid}
tunread={tunread}
toggleRead={toggleRead}
hideChannel={hideChannel}
testID={testID}

View File

@ -25,6 +25,7 @@ class Touchable extends React.Component {
favorite: PropTypes.bool,
isRead: PropTypes.bool,
rid: PropTypes.string,
tunread: PropTypes.array,
toggleFav: PropTypes.func,
toggleRead: PropTypes.func,
hideChannel: PropTypes.func,
@ -177,9 +178,12 @@ class Touchable extends React.Component {
};
toggleRead = () => {
const { toggleRead, rid, isRead } = this.props;
const {
toggleRead, rid, isRead, tunread
} = this.props;
if (toggleRead) {
toggleRead(rid, isRead);
toggleRead(rid, isRead, tunread);
}
};

View File

@ -632,18 +632,40 @@ class RoomsListView extends React.Component {
}
};
toggleRead = async(rid, isRead) => {
readThreads = async(tunread) => {
const result = [];
for (let i = 0; i < tunread.length; i += 1) {
const tmid = tunread[i];
try {
if (tmid) {
// eslint-disable-next-line no-await-in-loop
const response = await RocketChat.readThreads(tmid);
result.push(response.success);
}
} catch (e) {
logEvent(events.RL_TOGGLE_READ_F);
log(e);
}
}
return result.every(Boolean);
}
toggleRead = async(rid, isRead, tunread) => {
logEvent(isRead ? events.RL_UNREAD_CHANNEL : events.RL_READ_CHANNEL);
try {
const db = database.active;
const result = await RocketChat.toggleRead(isRead, rid);
if (result.success) {
const threadResult = tunread?.length > 0 ? await this.readThreads(tunread) : true;
if (result.success && threadResult) {
const subCollection = db.get('subscriptions');
await db.action(async() => {
try {
const subRecord = await subCollection.find(rid);
await subRecord.update((sub) => {
sub.alert = isRead;
sub.unread = 0;
sub.tunread = tunread && [];
});
} catch (e) {
log(e);