From b865074c328cbc3a6ba6319561c17daff6f958f9 Mon Sep 17 00:00:00 2001 From: chylex <contact@chylex.com> Date: Fri, 17 Aug 2018 07:02:22 +0200 Subject: [PATCH] Mark DMs as read when replying to them --- Resources/Scripts/code.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Resources/Scripts/code.js b/Resources/Scripts/code.js index 8ace9a3f..4d011976 100644 --- a/Resources/Scripts/code.js +++ b/Resources/Scripts/code.js @@ -1514,6 +1514,24 @@ }); } + // + // Block: Fix DMs not being marked as read when replying to them. + // + execSafe(function markRepliedDMsAsRead(){ + throw 1 if !ensurePropertyExists(TD, "controller", "clients", "getClient"); + throw 2 if !ensurePropertyExists(TD, "services", "Conversations", "prototype", "getConversation"); + + $(document).on("dataDmSent", function(e, data){ + let client = TD.controller.clients.getClient(data.request.accountKey); + return if !client; + + let conversation = client.conversations.getConversation(data.request.conversationId); + return if !conversation; + + conversation.markAsRead(); + }); + }); + // // Block: Limit amount of loaded DMs to avoid massive lag from re-opening them several times. //