Reset read receipt on sending sticker
authorAjay Bura <ajbura@gmail.com>
Sat, 6 Aug 2022 07:20:23 +0000 (12:50 +0530)
committerAjay Bura <ajbura@gmail.com>
Sat, 6 Aug 2022 07:20:23 +0000 (12:50 +0530)
src/app/organisms/room/RoomViewInput.jsx
src/client/state/RoomsInput.js

index 4a7b2bf78fab0251983bc5aabd5c66e88c5ce03b..63870131aba74a983e862e545c18ab5f3d1392ee 100644 (file)
@@ -207,30 +207,7 @@ function RoomViewInput({
   };
 
   const handleSendSticker = async (data) => {
-    const { mxc: url, body, httpUrl } = data;
-    const info = {};
-
-    const img = new Image();
-    img.src = httpUrl;
-
-    try {
-      const res = await fetch(httpUrl);
-      const blob = await res.blob();
-      info.w = img.width;
-      info.h = img.height;
-      info.mimetype = blob.type;
-      info.size = blob.size;
-      info.thumbnail_info = { ...info };
-      info.thumbnail_url = url;
-    } catch {
-      // send sticker without info
-    }
-
-    mx.sendEvent(roomId, 'm.sticker', {
-      body,
-      url,
-      info,
-    });
+    roomsInput.sendSticker(roomId, data);
   };
 
   function processTyping(msg) {
index 814255429d653bb5f2ebdebc1a3db5994388b185..b9215c85452af6e0f2d85dbe95a791239498c8a2 100644 (file)
@@ -6,7 +6,6 @@ import { math } from 'micromark-extension-math';
 import { encode } from 'blurhash';
 import { getShortcodeToEmoji } from '../../app/organisms/emoji-board/custom-emoji';
 import { mathExtensionHtml, spoilerExtension, spoilerExtensionHtml } from '../../util/markdown';
-import { getImageDimension } from '../../util/common';
 import cons from './cons';
 import settings from './settings';
 
@@ -312,6 +311,34 @@ class RoomsInput extends EventEmitter {
     this.emit(cons.events.roomsInput.MESSAGE_SENT, roomId);
   }
 
+  async sendSticker(roomId, data) {
+    const { mxc: url, body, httpUrl } = data;
+    const info = {};
+
+    const img = new Image();
+    img.src = httpUrl;
+
+    try {
+      const res = await fetch(httpUrl);
+      const blob = await res.blob();
+      info.w = img.width;
+      info.h = img.height;
+      info.mimetype = blob.type;
+      info.size = blob.size;
+      info.thumbnail_info = { ...info };
+      info.thumbnail_url = url;
+    } catch {
+      // send sticker without info
+    }
+
+    this.matrixClient.sendEvent(roomId, 'm.sticker', {
+      body,
+      url,
+      info,
+    });
+    this.emit(cons.events.roomsInput.MESSAGE_SENT, roomId);
+  }
+
   async sendFile(roomId, file) {
     const fileType = file.type.slice(0, file.type.indexOf('/'));
     const info = {