v3: linter and formatter pass

This commit is contained in:
khannurien
2026-03-22 16:08:12 +00:00
parent 34e908d1bc
commit a104113e05
17 changed files with 159 additions and 56 deletions

View File

@@ -125,7 +125,10 @@ export function Dump() {
if (!el) return;
el.scrollIntoView({ behavior: "smooth", block: "start" });
el.classList.add("comment-node--highlight");
const t = setTimeout(() => el.classList.remove("comment-node--highlight"), 2000);
const t = setTimeout(
() => el.classList.remove("comment-node--highlight"),
2000,
);
return () => clearTimeout(t);
}, [comments, location.hash]);

View File

@@ -5,7 +5,6 @@ import { Link, useNavigate } from "react-router";
import { API_URL } from "../config/api.ts";
import type { CreateUrlDumpRequest, RichContent } from "../model.ts";
import { useRequiredAuth } from "../hooks/useAuth.ts";
import { formatBytes } from "../utils/format.ts";
import { dumpUrl } from "../utils/urls.ts";
import { PageShell } from "../components/PageShell.tsx";
import RichContentCard from "../components/RichContentCard.tsx";

View File

@@ -97,7 +97,9 @@ function notificationLink(n: Notification): string {
return `/dumps/${(data as DumpUpvotedData).dumpId}`;
case "user_mentioned": {
const d = data as UserMentionedData;
if (d.contextType === "comment") return `/dumps/${d.dumpId}#comment-${d.contextId}`;
if (d.contextType === "comment") {
return `/dumps/${d.dumpId}#comment-${d.contextId}`;
}
if (d.contextType === "dump") return `/dumps/${d.contextId}`;
return `/playlists/${d.contextId}`;
}
@@ -109,28 +111,64 @@ function notificationContent(n: Notification): React.ReactNode {
switch (n.type) {
case "user_followed": {
const d = data as UserFollowedData;
return <><strong>{d.followerUsername}</strong>{" started following you"}</>;
return (
<>
<strong>{d.followerUsername}</strong>
{" started following you"}
</>
);
}
case "playlist_followed": {
const d = data as PlaylistFollowedData;
return <><strong>{d.followerUsername}</strong>{" followed your playlist "}<strong>{d.playlistTitle}</strong></>;
return (
<>
<strong>{d.followerUsername}</strong>
{" followed your playlist "}
<strong>{d.playlistTitle}</strong>
</>
);
}
case "user_dump_posted": {
const d = data as UserDumpPostedData;
return <><strong>{d.dumperUsername}</strong>{" posted "}<strong>{d.dumpTitle}</strong></>;
return (
<>
<strong>{d.dumperUsername}</strong>
{" posted "}
<strong>{d.dumpTitle}</strong>
</>
);
}
case "playlist_dump_added": {
const d = data as PlaylistDumpAddedData;
return <><strong>{d.dumpTitle}</strong>{" was added to "}<strong>{d.playlistTitle}</strong></>;
return (
<>
<strong>{d.dumpTitle}</strong>
{" was added to "}
<strong>{d.playlistTitle}</strong>
</>
);
}
case "dump_upvoted": {
const d = data as DumpUpvotedData;
return <><strong>{d.voterUsername}</strong>{" upvoted "}<strong>{d.dumpTitle}</strong></>;
return (
<>
<strong>{d.voterUsername}</strong>
{" upvoted "}
<strong>{d.dumpTitle}</strong>
</>
);
}
case "user_mentioned": {
const d = data as UserMentionedData;
const where = d.contextTitle || (d.contextType === "comment" ? "a comment" : "a post");
return <><strong>{d.mentionerUsername}</strong>{" mentioned you in "}<strong>{where}</strong></>;
const where = d.contextTitle ||
(d.contextType === "comment" ? "a comment" : "a post");
return (
<>
<strong>{d.mentionerUsername}</strong>
{" mentioned you in "}
<strong>{where}</strong>
</>
);
}
}
}

View File

@@ -341,7 +341,9 @@ export function PlaylistDetail() {
dumpMap.set(dump.id, dump);
const reinserted = order.length > 0
? [
...order.filter((id) => dumpMap.has(id)).map((id) => dumpMap.get(id)!),
...order.filter((id) => dumpMap.has(id)).map((id) =>
dumpMap.get(id)!
),
...prev.playlist.dumps.filter((d) => !new Set(order).has(d.id)),
]
: [...prev.playlist.dumps, dump];
@@ -684,7 +686,9 @@ export function PlaylistDetail() {
</time>
</Tooltip>
{playlist.updatedAt && (
<Tooltip text={`Edited ${playlist.updatedAt.toLocaleString()}`}>
<Tooltip
text={`Edited ${playlist.updatedAt.toLocaleString()}`}
>
<span className="playlist-edited-label">
edited {relativeTime(playlist.updatedAt)}
</span>
@@ -705,7 +709,9 @@ export function PlaylistDetail() {
: (
<div
className="playlist-dump-list"
onDragOver={isOwner ? (e) => e.preventDefault() : undefined}
onDragOver={isOwner
? (e) => e.preventDefault()
: undefined}
>
{visibleDumps.map((dump) => {
const isActive = activeDumpIds.has(dump.id);

View File

@@ -1,6 +1,6 @@
import { useState } from "react";
import type { SubmitEvent } from "react";
import { Link, useNavigate } from "react-router";
import { useNavigate } from "react-router";
import { API_URL } from "../config/api.ts";
import { deserializeAuthResponse } from "../model.ts";

View File

@@ -77,7 +77,9 @@ export function UserPlaylists() {
const setCreated = useCallback((fn: (prev: Playlist[]) => Playlist[]) => {
setState((s) =>
s.status !== "loaded" ? s : { ...s, created: { ...s.created, items: fn(s.created.items) } }
s.status !== "loaded"
? s
: { ...s, created: { ...s.created, items: fn(s.created.items) } }
);
}, []);
usePlaylistListSync(setCreated, {

View File

@@ -1,4 +1,10 @@
import React, { useCallback, useEffect, useLayoutEffect, useRef, useState } from "react";
import React, {
useCallback,
useEffect,
useLayoutEffect,
useRef,
useState,
} from "react";
import { Link, useNavigate, useParams } from "react-router";
import { API_URL } from "../config/api.ts";
@@ -151,7 +157,9 @@ export function UserPublicProfile() {
if (next.length < prev.length) {
const nextIds = new Set(next.map((d) => d.id));
prev.forEach((d, idx) => {
if (!nextIds.has(d.id)) removedDumpPositionsRef.current.set(d.id, idx);
if (!nextIds.has(d.id)) {
removedDumpPositionsRef.current.set(d.id, idx);
}
});
}
return { ...s, dumps: { ...s.dumps, items: next } };
@@ -180,7 +188,9 @@ export function UserPublicProfile() {
if (next.length < prev.length) {
const nextIds = new Set(next.map((d) => d.id));
prev.forEach((d, idx) => {
if (!nextIds.has(d.id)) removedVotePositionsRef.current.set(d.id, idx);
if (!nextIds.has(d.id)) {
removedVotePositionsRef.current.set(d.id, idx);
}
});
}
return { ...s, votes: { ...s.votes, items: next } };
@@ -422,7 +432,6 @@ export function UserPublicProfile() {
}
}, [lastVoteEvent, me, profileUserId]);
// Save scroll position + loaded state to sessionStorage on scroll
useEffect(() => {
if (state.status !== "loaded") return;