From 67936f53edb1ef244cec0a39dcb4bbf0974ce705 Mon Sep 17 00:00:00 2001 From: Paul Makles Date: Sun, 2 Jan 2022 16:07:47 +0000 Subject: [PATCH] revert: "fix(vite): remove "second" compression pass" This reverts commit 096e0c84c188b0ce8b385290051593bbea238de3. --- package.json | 1 + .../navigation/left/ServerListSidebar.tsx | 400 ++++++++---------- vite.config.ts | 5 + yarn.lock | 11 +- 4 files changed, 182 insertions(+), 235 deletions(-) diff --git a/package.json b/package.json index 32828ce4..5d6cb787 100644 --- a/package.json +++ b/package.json @@ -151,6 +151,7 @@ "typescript": "^4.4.2", "ulid": "^2.3.0", "use-resize-observer": "^7.0.0", + "vite-plugin-compression": "^0.3.6", "vite-plugin-pwa": "^0.8.1", "workbox-precaching": "^6.1.5" }, diff --git a/src/components/navigation/left/ServerListSidebar.tsx b/src/components/navigation/left/ServerListSidebar.tsx index 14ce9e01..6b531ef9 100644 --- a/src/components/navigation/left/ServerListSidebar.tsx +++ b/src/components/navigation/left/ServerListSidebar.tsx @@ -1,18 +1,15 @@ import { Plus, LinkExternal } from "@styled-icons/boxicons-regular"; import { Cog, Compass } from "@styled-icons/boxicons-solid"; import { observer } from "mobx-react-lite"; -import { DragDropContext } from "react-beautiful-dnd"; import { Link, useHistory, useLocation, useParams } from "react-router-dom"; import { RelationshipStatus } from "revolt-api/types/Users"; import styled, { css } from "styled-components"; import { attachContextMenu } from "preact-context-menu"; import { Text } from "preact-i18n"; -import { useState } from "preact/hooks"; import ConditionalLink from "../../../lib/ConditionalLink"; import PaintCounter from "../../../lib/PaintCounter"; -import { Draggable, Droppable } from "../../../lib/dnd"; import { isTouchscreenDevice } from "../../../lib/isTouchscreenDevice"; import { useApplicationState } from "../../../mobx/State"; @@ -238,7 +235,7 @@ export default observer(() => { const { server: server_id } = useParams<{ server?: string }>(); const server = server_id ? client.servers.get(server_id) : undefined; - const [servers, setServers] = useState([...client.servers.values()]); + const servers = [...client.servers.values()]; const channels = [...client.channels.values()]; const history = useHistory(); @@ -253,246 +250,181 @@ export default observer(() => { typeof server === "undefined" && !path.startsWith("/invite"); return ( - { - if (target.destination) { - const arr = [...servers]; - arr.splice( - target.destination.index, - 0, - arr.splice(target.source.index, 1)[0], - ); - setServers(arr); - } - }}> - - - {(provided) => ( - - - - -
- homeActive && - history.push("/settings") - }> - - 0 - ? "mention" - : undefined - } - count={alertCount}> + + + + + +
+ homeActive && history.push("/settings") + }> + + 0 ? "mention" : undefined + } + count={alertCount}> + + + +
+
+
+ {channels + .filter( + (x) => + (x.channel_type === "DirectMessage" || + x.channel_type === "Group") && + x.unread, + ) + .map((x) => { + const unreadCount = x.mentions.length; + return ( + + +
+ 0 + ? "mention" + : "unread" + } + count={unreadCount}> + {x.channel_type === + "DirectMessage" ? ( - - + ) : ( + + )} +
- - {channels - .filter( - (x) => - (x.channel_type === "DirectMessage" || - x.channel_type === "Group") && - x.unread, - ) - .map((x) => { - const unreadCount = x.mentions.length; - return ( - - -
- 0 - ? "mention" - : "unread" - } - count={unreadCount}> - {x.channel_type === - "DirectMessage" ? ( - - ) : ( - - )} - -
-
- - ); - })} - - {servers.map((server, index) => { - const active = server._id === server_id; + + ); + })} + + {servers.map((server) => { + const active = server._id === server_id; - const isUnread = server.isUnread( - state.notifications, - ); - const mentionCount = server.getMentions( - state.notifications, - ).length; + const isUnread = server.isUnread(state.notifications); + const mentionCount = server.getMentions( + state.notifications, + ).length; - return ( - - {(provided, snapshot) => ( -
- - - {!snapshot.isDragging && ( - - )} - - - - 0 - ? "mention" - : isUnread - ? "unread" - : undefined - } - count={ - mentionCount - }> - - - - - -
- )} -
- ); - })} - {provided.placeholder} - + return ( + + + -
- - openScreen({ - id: "special_input", - type: "create_server", - }) - }> - - -
+ 0 + ? "mention" + : isUnread + ? "unread" + : undefined + } + count={mentionCount}> + +
-
- - -
Discover Public Servers
- -
- } - placement="right"> -
- - - - - -
- - -
- )} -
- - {!isTouchscreenDevice && ( - - - } - placement="right"> - - - - - - - )} -
-
+ + + ); + })} + {/**/} + + +
+ + openScreen({ + id: "special_input", + type: "create_server", + }) + }> + + +
+
+
+ + +
Discover Public Servers
+ + + } + placement="right"> +
+ + + + + +
+
+
+ + + {!isTouchscreenDevice && ( + + + } + placement="right"> + + + + + + + )} + ); }); diff --git a/vite.config.ts b/vite.config.ts index 781f9b9e..247f1f32 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -2,6 +2,7 @@ import replace from "@rollup/plugin-replace"; import { readFileSync } from "fs"; import { resolve } from "path"; import { defineConfig } from "vite"; +import viteCompression from "vite-plugin-compression"; import { VitePWA } from "vite-plugin-pwa"; import preact from "@preact/preset-vite"; @@ -42,6 +43,10 @@ function getVersion() { export default defineConfig({ plugins: [ + viteCompression({ + verbose: true, + algorithm: "brotliCompress", + }), preact(), VitePWA({ srcDir: "src", diff --git a/yarn.lock b/yarn.lock index 5ade8187..688dfdfb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1887,7 +1887,7 @@ chalk@^2.0.0: escape-string-regexp "^1.0.5" supports-color "^5.3.0" -chalk@^4.0.0: +chalk@^4.0.0, chalk@^4.1.2: version "4.1.2" resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01" integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA== @@ -4357,6 +4357,15 @@ value-equal@^1.0.1: resolved "https://registry.yarnpkg.com/value-equal/-/value-equal-1.0.1.tgz#1e0b794c734c5c0cade179c437d356d931a34d6c" integrity sha512-NOJ6JZCAWr0zlxZt+xqCHNTEKOsrks2HQd4MqhP1qy4z1SkbEP467eNx6TgDKXMvUOb+OENfJCZwM+16n7fRfw== +vite-plugin-compression@^0.3.6: + version "0.3.6" + resolved "https://registry.yarnpkg.com/vite-plugin-compression/-/vite-plugin-compression-0.3.6.tgz#85e3ce5047ae6747bc3952177177a852fac901be" + integrity sha512-aSskQCJsP3VQ8PsnY+vO7UfD5qoFMOEuzg0PG2E9Zqyx+ARmc3wr9KCgOFraZOFW1Y4UAa5BR0SMTjoxHRMJoQ== + dependencies: + chalk "^4.1.2" + debug "^4.3.2" + fs-extra "^10.0.0" + vite-plugin-pwa@^0.8.1: version "0.8.2" resolved "https://registry.yarnpkg.com/vite-plugin-pwa/-/vite-plugin-pwa-0.8.2.tgz#2789a157e2f71faf834d968945efc22eee9ad64a"