From 3c6a86deb85e7d919c180a0a57b2f9e5639af696 Mon Sep 17 00:00:00 2001 From: sphinxrave <62570796+sphinxrave@users.noreply.github.com> Date: Wed, 13 Nov 2024 01:41:07 -0800 Subject: [PATCH] nit --- packages/react/package-lock.json | 210 +++++++++++++++++- packages/react/package.json | 1 + .../react/src/components/layout/Frame.tsx | 14 ++ .../react/src/components/sidebar/sidebar.tsx | 27 ++- .../react/src/components/video/VideoCard.tsx | 2 +- .../video/VideoCardCountdownToLive.tsx | 51 +++-- packages/react/tsconfig.json | 1 + packages/react/vite.config.ts | 31 +++ 8 files changed, 313 insertions(+), 24 deletions(-) diff --git a/packages/react/package-lock.json b/packages/react/package-lock.json index 293cb0f77..f434192d3 100644 --- a/packages/react/package-lock.json +++ b/packages/react/package-lock.json @@ -132,6 +132,7 @@ "typescript-plugin-css-modules": "^5.1.0", "unocss": "^0.61.3", "unocss-preset-autoprefixer": "^0.0.7", + "unplugin-info": "^1.2.1", "vite": "^5.3.4" } }, @@ -1833,6 +1834,23 @@ "@jridgewell/sourcemap-codec": "^1.4.14" } }, + "node_modules/@kwsites/file-exists": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@kwsites/file-exists/-/file-exists-1.1.1.tgz", + "integrity": "sha512-m9/5YGR18lIwxSFDwfE3oA7bWuq9kdau6ugN4H2rJeyhFQZcG9AgSHkQtSD15a8WvTgfz9aikZMrKPHvbpqFiw==", + "dev": true, + "license": "MIT", + "dependencies": { + "debug": "^4.1.1" + } + }, + "node_modules/@kwsites/promise-deferred": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@kwsites/promise-deferred/-/promise-deferred-1.1.1.tgz", + "integrity": "sha512-GaHYm+c0O9MjZRu0ongGBRbinu8gVAMd2UZjji6jVmqKtZluZnptXGWhz1E8j8D2HJ3f/yMxKAUC0b+57wncIw==", + "dev": true, + "license": "MIT" + }, "node_modules/@losting/timeline": { "version": "2.3.0", "resolved": "git+ssh://git@github.com/sphinxrave/timeline.git#a84c6aa61eb0b4301a93ed975a5d18ef66dd6b48", @@ -5317,10 +5335,11 @@ "integrity": "sha512-N8tkAACJx2ww8vFMneJmaAgmjAG1tnVBZJRLRcx061tmsLRZHSEZSLuGWnwPtunsSLvSqXQ2wfp7Mgqg1I+2dQ==" }, "node_modules/acorn": { - "version": "8.11.3", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.3.tgz", - "integrity": "sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==", + "version": "8.14.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.14.0.tgz", + "integrity": "sha512-cl669nCJTZBsL97OF4kUQm5g5hC2uihk0NxY3WENAC0TYdILVkAyHymAntgxGkl7K+t0cXIrH5siy5S4XkFycA==", "dev": true, + "license": "MIT", "bin": { "acorn": "bin/acorn" }, @@ -5644,6 +5663,22 @@ "node": ">= 6" } }, + "node_modules/ci-info": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-4.1.0.tgz", + "integrity": "sha512-HutrvTNsF48wnxkzERIXOe5/mlcfFcbfCmwcg6CJnizbSue78AbDt+1cgl26zwn61WFxhcPykPfZrbqjGmBb4A==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/sibiraj-s" + } + ], + "license": "MIT", + "engines": { + "node": ">=8" + } + }, "node_modules/class-variance-authority": { "version": "0.7.0", "resolved": "https://registry.npmjs.org/class-variance-authority/-/class-variance-authority-0.7.0.tgz", @@ -7192,6 +7227,27 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/git-up": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/git-up/-/git-up-7.0.0.tgz", + "integrity": "sha512-ONdIrbBCFusq1Oy0sC71F5azx8bVkvtZtMJAsv+a6lz5YAmbNnLD6HAB4gptHZVLPR8S2/kVN6Gab7lryq5+lQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-ssh": "^1.4.0", + "parse-url": "^8.1.0" + } + }, + "node_modules/git-url-parse": { + "version": "15.0.0", + "resolved": "https://registry.npmjs.org/git-url-parse/-/git-url-parse-15.0.0.tgz", + "integrity": "sha512-5reeBufLi+i4QD3ZFftcJs9jC26aULFLBU23FeKM/b1rI0K6ofIeAblmDVO7Ht22zTDE9+CkJ3ZVb0CgJmz3UQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "git-up": "^7.0.0" + } + }, "node_modules/glob": { "version": "7.2.3", "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", @@ -7628,6 +7684,16 @@ "node": ">=8" } }, + "node_modules/is-ssh": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/is-ssh/-/is-ssh-1.4.0.tgz", + "integrity": "sha512-x7+VxdxOdlV3CYpjvRLBv5Lo9OJerlYanjwFrPR9fuGPjCiNiCzFgAWpiLAohSbsnH4ZAys3SBh+hq5rJosxUQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "protocols": "^2.0.1" + } + }, "node_modules/is-stream": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-3.0.0.tgz", @@ -8883,6 +8949,26 @@ "node": ">= 0.10" } }, + "node_modules/parse-path": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/parse-path/-/parse-path-7.0.0.tgz", + "integrity": "sha512-Euf9GG8WT9CdqwuWJGdf3RkUcTBArppHABkO7Lm8IzRQp0e2r/kkFnmhu4TSK30Wcu5rVAZLmfPKSBBi9tWFog==", + "dev": true, + "license": "MIT", + "dependencies": { + "protocols": "^2.0.0" + } + }, + "node_modules/parse-url": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/parse-url/-/parse-url-8.1.0.tgz", + "integrity": "sha512-xDvOoLU5XRrcOZvnI6b8zA6n9O9ejNk/GExuz1yBuWUGn9KA97GI6HTs6u02wKara1CeVmZhH+0TZFdWScR89w==", + "dev": true, + "license": "MIT", + "dependencies": { + "parse-path": "^7.0.0" + } + }, "node_modules/path-exists": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", @@ -9346,6 +9432,13 @@ "node": ">=0.10.0" } }, + "node_modules/protocols": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/protocols/-/protocols-2.0.1.tgz", + "integrity": "sha512-/XJ368cyBJ7fzLMwLKv1e4vLxOju2MNAIokcr7meSaNcVbWz/CPcW22cP04mwxOErdA5mwjA8Q6w/cdAQxVn7Q==", + "dev": true, + "license": "MIT" + }, "node_modules/protoframe": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/protoframe/-/protoframe-1.1.1.tgz", @@ -10272,6 +10365,47 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/simple-git": { + "version": "3.27.0", + "resolved": "https://registry.npmjs.org/simple-git/-/simple-git-3.27.0.tgz", + "integrity": "sha512-ivHoFS9Yi9GY49ogc6/YAi3Fl9ROnF4VyubNylgCkA+RVqLaKWnDSzXOVzya8csELIaWaYNutsEuAhZrtOjozA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@kwsites/file-exists": "^1.1.1", + "@kwsites/promise-deferred": "^1.1.1", + "debug": "^4.3.5" + }, + "funding": { + "type": "github", + "url": "https://github.com/steveukx/git-js?sponsor=1" + } + }, + "node_modules/simple-git/node_modules/debug": { + "version": "4.3.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz", + "integrity": "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/simple-git/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true, + "license": "MIT" + }, "node_modules/simple-swizzle": { "version": "0.2.2", "resolved": "https://registry.npmjs.org/simple-swizzle/-/simple-swizzle-0.2.2.tgz", @@ -11115,6 +11249,69 @@ "url": "https://github.com/sponsors/antfu" } }, + "node_modules/unplugin": { + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/unplugin/-/unplugin-1.15.0.tgz", + "integrity": "sha512-jTPIs63W+DUEDW207ztbaoO7cQ4p5aVaB823LSlxpsFEU3Mykwxf3ZGC/wzxFJeZlASZYgVrWeo7LgOrqJZ8RA==", + "dev": true, + "license": "MIT", + "dependencies": { + "acorn": "^8.14.0", + "webpack-virtual-modules": "^0.6.2" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "webpack-sources": "^3" + }, + "peerDependenciesMeta": { + "webpack-sources": { + "optional": true + } + } + }, + "node_modules/unplugin-info": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/unplugin-info/-/unplugin-info-1.2.1.tgz", + "integrity": "sha512-NwssEGmXCBYnGE3i9UhhK1nva1GF8EU21mBGmGZQVOYZwmNHOs+wcwgGnHsmc1nX4PkVQTLiawaLQBeP6HJKkA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ci-info": "^4.0.0", + "git-url-parse": "^15.0.0", + "simple-git": "^3.27.0", + "unplugin": "^1.14.1" + }, + "peerDependencies": { + "@nuxt/kit": "^3", + "@nuxt/schema": "^3", + "esbuild": "*", + "rollup": "^2 || ^3 || ^4", + "vite": ">=3.2.7", + "webpack": "^4 || ^5" + }, + "peerDependenciesMeta": { + "@nuxt/kit": { + "optional": true + }, + "@nuxt/schema": { + "optional": true + }, + "esbuild": { + "optional": true + }, + "rollup": { + "optional": true + }, + "vite": { + "optional": true + }, + "webpack": { + "optional": true + } + } + }, "node_modules/update-browserslist-db": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.1.1.tgz", @@ -11380,6 +11577,13 @@ "node": ">=0.10.0" } }, + "node_modules/webpack-virtual-modules": { + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/webpack-virtual-modules/-/webpack-virtual-modules-0.6.2.tgz", + "integrity": "sha512-66/V2i5hQanC51vBQKPH4aI8NMAcBW59FVBs+rC7eGHupMyfn34q7rZIE+ETlJ+XTevqfUhVVBgSUNSW2flEUQ==", + "dev": true, + "license": "MIT" + }, "node_modules/which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", diff --git a/packages/react/package.json b/packages/react/package.json index 6b181975a..cbe7333dd 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -139,6 +139,7 @@ "typescript-plugin-css-modules": "^5.1.0", "unocss": "^0.61.3", "unocss-preset-autoprefixer": "^0.0.7", + "unplugin-info": "^1.2.1", "vite": "^5.3.4" } } diff --git a/packages/react/src/components/layout/Frame.tsx b/packages/react/src/components/layout/Frame.tsx index f212c8b4d..ba9515580 100644 --- a/packages/react/src/components/layout/Frame.tsx +++ b/packages/react/src/components/layout/Frame.tsx @@ -30,6 +30,14 @@ import React from "react"; import { useOrgs } from "@/services/orgs.service"; import { useTimeout } from "usehooks-ts"; import { defaultOpenAtom } from "@/store/settings"; +//@ts-expect-error commitssincelasttag +import { + abbreviatedSha, + committerDate, + lastTag, + commitsSinceLastTag, +} from "~build/git"; +import dayjs from "dayjs"; export function LocationAwareReactivity() { const location = useLocation(); @@ -142,6 +150,12 @@ export function Frame() { +
+ © 2020 Holodex v{lastTag}.{commitsSinceLastTag} + + {abbreviatedSha} / {dayjs(new Date(committerDate)).format("lll")} + +
{reportedVideo && ( diff --git a/packages/react/src/components/sidebar/sidebar.tsx b/packages/react/src/components/sidebar/sidebar.tsx index 47e2e0938..f16c12a22 100644 --- a/packages/react/src/components/sidebar/sidebar.tsx +++ b/packages/react/src/components/sidebar/sidebar.tsx @@ -3,7 +3,13 @@ import { Button } from "@/shadcn/ui/button"; import { useAtom, useAtomValue, useSetAtom } from "jotai"; import { OrgSelectorCombobox } from "../org/OrgSelectorCombobox"; import { useTranslation } from "react-i18next"; -import { Link, useLocation } from "react-router-dom"; +import { + Link, + useLocation, + useNavigate, + useParams, + useSearchParams, +} from "react-router-dom"; import { HTMLAttributes, type ReactNode, @@ -36,6 +42,23 @@ export function Sidebar() { const isMobile = useAtomValue(isMobileAtom); const toggle = useSetAtom(toggleSidebarAtom); const fs = useAtomValue(sidebarShouldBeFullscreenAtom); + const navigate = useNavigate(); + const org = useParams().org; + const [params] = useSearchParams(); + + const setOrg = useCallback( + (org?: Org) => { + navigate({ + pathname: `/org/${org?.name}`, + search: ["members", "live", "clips", "archive"].includes( + params.get("tab") || "", + ) + ? `?tab=${params.get("tab")}` + : "", + }); + }, + [navigate, params], + ); const handleClickOutside = useCallback(() => { floating && open && setOpen(false); @@ -62,7 +85,7 @@ export function Sidebar() {
- +
{ - const { t } = useTranslation(); +const LiveCounter = React.memo( + ({ viewers, className, start_date }: LiveCounterProps) => { + const { t } = useTranslation(); - return ( -
- {t("component.videoCard.liveNow")} - {viewers && ( - <> - / - - {t("component.videoCard.watching", { - 0: formatCount(viewers), - })} + return ( +
+ {start_date || viewers ? ( + + {t("component.videoCard.liveNow")} - - )} -
- ); -}); + ) : ( + {t("time.soon")} + )} + {start_date && viewers && viewers > 0 ? ( + <> + / + + {t("component.videoCard.watching", { + 0: formatCount(viewers), + })} + + + ) : null} +
+ ); + }, +); interface TimeTooltipProps { id: string; @@ -89,7 +98,13 @@ export function VideoCardCountdownToLive({ // Early return for live videos if (video.status === "live") { - return ; + return ( + + ); } // Handle upcoming videos diff --git a/packages/react/tsconfig.json b/packages/react/tsconfig.json index ed925768a..deec8e5f3 100644 --- a/packages/react/tsconfig.json +++ b/packages/react/tsconfig.json @@ -44,6 +44,7 @@ "@types/wicg-file-system-access", "@types/node", "vite/client", + "unplugin-info/client" ] }, "include": [ diff --git a/packages/react/vite.config.ts b/packages/react/vite.config.ts index df5f0352f..ab5e648c9 100644 --- a/packages/react/vite.config.ts +++ b/packages/react/vite.config.ts @@ -11,6 +11,7 @@ import UnoCSS from "unocss/vite"; import presetIcons from "@unocss/preset-icons"; import { fileURLToPath, URL } from "url"; import bundleAnalyzer from "rollup-plugin-bundle-analyzer"; +import BuildInfo from "unplugin-info/vite"; // import react from "@vitejs/plugin-react"; // yeah idk why there's a lot of typescript errors in this file. @@ -60,6 +61,36 @@ export default defineConfig({ }, }, plugins: [ + BuildInfo({ + git: { + // Gets whether this represents a clean working branch. + isClean: async (git) => { + const status = await git.status(); + return status.isClean(); + }, + commitsSinceLastTag: async (git) => { + // Get all tags sorted by date (newest first) + const tags = await git.tags(); + + if (tags.all.length === 0) { + // If no tags exist, return total number of commits + const log = await git.log(); + return log.total; + } + + // Get the most recent tag + const latestTag = tags.latest; + + // Count commits between latest tag and HEAD + const logResult = await git.log({ + from: latestTag, + to: "HEAD", + }); + + return logResult.total; + }, + }, + }), bundleAnalyzer({ analyzerMode: process.env["HOME"]?.includes("/home/holodex") ? "static" // don't use server mode when compiling on the linux server