From 8872ed56b15ade6814e80880e52513db140a23df Mon Sep 17 00:00:00 2001 From: Paul Date: Sat, 31 Jul 2021 17:58:26 +0100 Subject: [PATCH] Fix blocked users appearing in typing indicator. Make typing indicator time out. --- package.json | 2 +- .../common/messaging/MessageBox.tsx | 2 +- .../common/messaging/bars/TypingIndicator.tsx | 6 +- vite.config.ts | 177 +++++++++--------- yarn.lock | 8 +- 5 files changed, 102 insertions(+), 93 deletions(-) diff --git a/package.json b/package.json index 5b35789f..cd43168f 100644 --- a/package.json +++ b/package.json @@ -97,7 +97,7 @@ "react-router-dom": "^5.2.0", "react-scroll": "^1.8.2", "redux": "^4.1.0", - "revolt.js": "5.0.0-alpha.17", + "revolt.js": "5.0.0-alpha.18", "rimraf": "^3.0.2", "sass": "^1.35.1", "shade-blend-color": "^1.0.0", diff --git a/src/components/common/messaging/MessageBox.tsx b/src/components/common/messaging/MessageBox.tsx index bd35492f..0ac9f31c 100644 --- a/src/components/common/messaging/MessageBox.tsx +++ b/src/components/common/messaging/MessageBox.tsx @@ -323,7 +323,7 @@ export default observer(({ channel }: Props) => { const ws = client.websocket; if (ws.connected) { - setTyping(+new Date() + 4000); + setTyping(+new Date() + 2500); ws.send({ type: "BeginTyping", channel: channel._id, diff --git a/src/components/common/messaging/bars/TypingIndicator.tsx b/src/components/common/messaging/bars/TypingIndicator.tsx index b35ce144..4358c237 100644 --- a/src/components/common/messaging/bars/TypingIndicator.tsx +++ b/src/components/common/messaging/bars/TypingIndicator.tsx @@ -1,4 +1,5 @@ import { observer } from "mobx-react-lite"; +import { RelationshipStatus } from "revolt-api/types/Users"; import { Channel } from "revolt.js/dist/maps/Channels"; import styled from "styled-components"; @@ -57,7 +58,10 @@ const Base = styled.div` export default observer(({ channel }: Props) => { const users = channel.typing.filter( - (x) => typeof x !== "undefined" && x._id !== x.client.user!._id, + (x) => + typeof x !== "undefined" && + x._id !== x.client.user!._id && + x.relationship !== RelationshipStatus.Blocked, ); if (users.length > 0) { diff --git a/vite.config.ts b/vite.config.ts index 39e1b583..2a863e12 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,103 +1,108 @@ -import { resolve } from 'path' -import { readFileSync } from 'fs' -import { defineConfig } from 'vite' -import preact from '@preact/preset-vite' -import { VitePWA } from 'vite-plugin-pwa' -import replace from '@rollup/plugin-replace' +import replace from "@rollup/plugin-replace"; +import { readFileSync } from "fs"; +import { resolve } from "path"; +import { defineConfig } from "vite"; +import { VitePWA } from "vite-plugin-pwa"; + +import preact from "@preact/preset-vite"; function getGitRevision() { - try { - const rev = readFileSync('.git/HEAD').toString().trim(); - if (rev.indexOf(':') === -1) { - return rev; - } else { - return readFileSync('.git/' + rev.substring(5)).toString().trim(); + try { + const rev = readFileSync(".git/HEAD").toString().trim(); + if (rev.indexOf(":") === -1) { + return rev; + } else { + return readFileSync(".git/" + rev.substring(5)) + .toString() + .trim(); + } + } catch (err) { + console.error("Failed to get Git revision."); + return "?"; } - } catch (err) { - console.error('Failed to get Git revision.'); - return '?'; - } } function getGitBranch() { - try { - const rev = readFileSync('.git/HEAD').toString().trim(); - if (rev.indexOf(':') === -1) { - return 'DETACHED'; - } else { - return rev.split('/').pop(); + try { + const rev = readFileSync(".git/HEAD").toString().trim(); + if (rev.indexOf(":") === -1) { + return "DETACHED"; + } else { + return rev.split("/").pop(); + } + } catch (err) { + console.error("Failed to get Git branch."); + return "?"; } - } catch (err) { - console.error('Failed to get Git branch.'); - return '?'; - } } function getVersion() { - return readFileSync('VERSION').toString(); + return readFileSync("VERSION").toString(); } const branch = getGitBranch(); -const isNightly = false;//branch !== 'production'; -const iconPrefix = isNightly ? 'nightly-' : ''; +const isNightly = false; //branch !== 'production'; +const iconPrefix = isNightly ? "nightly-" : ""; export default defineConfig({ - plugins: [ - preact(), - VitePWA({ - srcDir: 'src', - filename: 'sw.ts', - strategies: 'injectManifest', - manifest: { - name: isNightly ? "Revolt Nightly" : "Revolt", - short_name: "Revolt", - description: isNightly ? "Early preview builds of Revolt." : "User-first, privacy-focused chat platform.", - categories: ["messaging"], - start_url: "/", - orientation: "portrait", - display: "standalone", - background_color: "#101823", - theme_color: "#101823", - icons: [ - { - "src": `/assets/icons/${iconPrefix}android-chrome-192x192.png`, - "type": "image/png", - "sizes": "192x192" + plugins: [ + preact(), + VitePWA({ + srcDir: "src", + filename: "sw.ts", + strategies: "injectManifest", + manifest: { + name: isNightly ? "Revolt Nightly" : "Revolt", + short_name: "Revolt", + description: isNightly + ? "Early preview builds of Revolt." + : "User-first, privacy-focused chat platform.", + categories: ["messaging"], + start_url: "/", + orientation: "portrait", + display: "standalone", + background_color: "#101823", + theme_color: "#101823", + icons: [ + { + src: `/assets/icons/${iconPrefix}android-chrome-192x192.png`, + type: "image/png", + sizes: "192x192", + }, + { + src: `/assets/icons/${iconPrefix}android-chrome-512x512.png`, + type: "image/png", + sizes: "512x512", + }, + { + src: `/assets/icons/monochrome.svg`, + type: "image/svg+xml", + sizes: "48x48 72x72 96x96 128x128 256x256", + purpose: "monochrome", + }, + { + src: `/assets/icons/masking-512x512.png`, + type: "image/png", + sizes: "512x512", + purpose: "maskable", + }, + ], }, - { - "src": `/assets/icons/${iconPrefix}android-chrome-512x512.png`, - "type": "image/png", - "sizes": "512x512" + }), + replace({ + __GIT_REVISION__: getGitRevision(), + __GIT_BRANCH__: getGitBranch(), + __APP_VERSION__: getVersion(), + preventAssignment: true, + }), + ], + build: { + sourcemap: true, + rollupOptions: { + input: { + main: resolve(__dirname, "index.html"), + ui: resolve(__dirname, "ui/index.html"), }, - { - "src": `/assets/icons/monochrome.svg`, - "type": "image/svg+xml", - "sizes": "48x48 72x72 96x96 128x128 256x256", - "purpose": "monochrome" - }, - { - "src": `/assets/icons/masking-512x512.png`, - "type": "image/png", - "sizes": "512x512", - "purpose": "maskable" - } - ] - } - }), - replace({ - __GIT_REVISION__: getGitRevision(), - __GIT_BRANCH__: getGitBranch(), - __APP_VERSION__: getVersion(), - preventAssignment: true - }) - ], - build: { - sourcemap: true, - rollupOptions: { - input: { - main: resolve(__dirname, 'index.html'), - ui: resolve(__dirname, 'ui/index.html') - } - } - } -}) + }, + }, +}); diff --git a/yarn.lock b/yarn.lock index 443a8e21..93435903 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3570,10 +3570,10 @@ revolt-api@0.5.1-alpha.10-patch.0: resolved "https://registry.yarnpkg.com/revolt-api/-/revolt-api-0.5.1-alpha.10-patch.0.tgz#97d31bec7dfa4573567097443acb059c4feaac20" integrity sha512-UyM890HkGlYNQOxpHuEpUsJHLt8Ujnjg9/zPEDGpbvS4iy0jmHX23Hh8tOCfb/ewxbNrtT3G1HpSWKOneW/vYg== -revolt.js@5.0.0-alpha.17: - version "5.0.0-alpha.17" - resolved "https://registry.yarnpkg.com/revolt.js/-/revolt.js-5.0.0-alpha.17.tgz#a0cb48327a7904379a5099b46b24a484b1d08b20" - integrity sha512-anEece/7V2tSszOWSKYakNHqWZHwGsAVpVL9CAtKNsF+bC+2C/7UhTsWL5w2g3FxJd7tobrEuck0by7ULnOvLw== +revolt.js@5.0.0-alpha.18: + version "5.0.0-alpha.18" + resolved "https://registry.yarnpkg.com/revolt.js/-/revolt.js-5.0.0-alpha.18.tgz#fffd63a4f4f93a4a6422de6a68c1ba3f3f9b55e5" + integrity sha512-NVd00P4CYLVJf1AuYwo65mPeLaST/RdU7dMLFwCZPvQAHvyPwTfLekCc9dfKPT4BkS2sjF8Vxi2xUFpMRMZYfw== dependencies: axios "^0.19.2" eventemitter3 "^4.0.7"