Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only change read status if in the same tab #210

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 20 additions & 12 deletions src/partials/messenger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -552,18 +552,26 @@ class ConversationController {
* avoid sending too many messages at once.
*/
public msgRead(msgId: number): void {
if (msgId > this.lastReadMsgId) {
this.lastReadMsgId = msgId;
}
if (!this.msgReadReportPending) {
this.msgReadReportPending = true;
const receiver = angular.copy(this.receiver);
receiver.type = this.type;
this.$timeout(() => {
this.webClientService.requestRead(receiver, this.lastReadMsgId);
this.msgReadReportPending = false;
}, 500);
}
var type = this.type;
var parentClass = this;
function checkHidden(parentClass, type) {
if (!document.hidden) {
clearInterval(_hiddenCheck);
if (msgId > parentClass.lastReadMsgId) {
parentClass.lastReadMsgId = msgId;
}
if (!parentClass.msgReadReportPending) {
parentClass.msgReadReportPending = true;
const receiver = angular.copy(parentClass.receiver);
receiver.type = type;
parentClass.$timeout(() => {
parentClass.webClientService.requestRead(receiver, parentClass.lastReadMsgId);
parentClass.msgReadReportPending = false;
}, 500);
}
}
}
var _hiddenCheck = setInterval(function(){checkHidden(parentClass,type)},500);
}

public goBack(): void {
Expand Down