From 1a7f92eb139a54244dd9e69d204c484af9dc585e Mon Sep 17 00:00:00 2001 From: Raphael Husistein Date: Wed, 26 Apr 2017 22:13:51 +0200 Subject: [PATCH 1/2] fixed little typo --- src/directives/compose_area.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/directives/compose_area.ts b/src/directives/compose_area.ts index a5c3240d6..8ce3c732f 100644 --- a/src/directives/compose_area.ts +++ b/src/directives/compose_area.ts @@ -82,7 +82,7 @@ export default [ /** * Stop propagation of click events and hold htmlElement of the emojipicker */ - let EmoijPickerContainer = (function() { + let EmojiPickerContainer = (function() { let instance; function click(e) { @@ -370,7 +370,7 @@ export default [ // Show emoji picker element function showEmojiPicker() { - const emojiPicker: HTMLElement = EmoijPickerContainer.get().htmlElement; + const emojiPicker: HTMLElement = EmojiPickerContainer.get().htmlElement; // Show emojiKeyboard.addClass('active'); @@ -396,11 +396,11 @@ export default [ // Find all emoji const allEmoji: any = angular.element( - EmoijPickerContainer.get().htmlElement.querySelectorAll('.content .e1')); + EmojiPickerContainer.get().htmlElement.querySelectorAll('.content .e1')); // Remove event handlers allEmoji.off('click', onEmojiChosen); - EmoijPickerContainer.destroy(); + EmojiPickerContainer.destroy(); } // Emoji trigger is clicked From 12cc5942d06cfddd4189d808dfbe5d3bd8441326 Mon Sep 17 00:00:00 2001 From: Raphael Husistein Date: Tue, 2 May 2017 00:54:37 +0200 Subject: [PATCH 2/2] only change read status if the chat is in the active browser tab --- src/partials/messenger.ts | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/src/partials/messenger.ts b/src/partials/messenger.ts index c577de915..2413ed48b 100644 --- a/src/partials/messenger.ts +++ b/src/partials/messenger.ts @@ -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 {