Skip to content

see more btn and media loading#2173

Merged
ragnep merged 3 commits intomainfrom
quick-vote-modal-fixes
Mar 27, 2026
Merged

see more btn and media loading#2173
ragnep merged 3 commits intomainfrom
quick-vote-modal-fixes

Conversation

@ragnep
Copy link
Copy Markdown
Contributor

@ragnep ragnep commented Mar 27, 2026

Summary by CodeRabbit

  • New Features

    • Added a dynamic "See more / See less" toggle for descriptions that overflow the collapsed view.
  • UI/Visual

    • Updated scrollbar styling for a cleaner, thinner appearance.
    • Refined loading/skeleton visuals with a more consistent iron-toned color palette.

Signed-off-by: ragnep <ragneinfo@gmail.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 27, 2026

Warning

Rate limit exceeded

@ragnep has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 11 minutes and 52 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 11 minutes and 52 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 687682ed-4f41-4f73-8c1d-5e405aca3c20

📥 Commits

Reviewing files that changed from the base of the PR and between afa781b and 7fc6601.

📒 Files selected for processing (1)
  • components/drops/view/item/content/media/DropListItemContentMediaImage.tsx
📝 Walkthrough

Walkthrough

Adds a dynamic expandable description component for the Memes Quick Vote UI with DOM-based overflow detection, replaces scrollbar-hiding CSS with explicit thin scrollbar styling, updates skeleton UI colors to an iron palette, and applies small tweaks to media-rendering files (lint/comment, promise ignore, and a minor switch in unreachable handling).

Changes

Cohort / File(s) Summary
Memes Quick Vote UI
components/brain/left-sidebar/waves/memes-quick-vote/MemesQuickVoteControls.tsx
Added MemesQuickVoteDescription component with isExpanded/isOverflowing state, DOM height-based overflow detection, ResizeObserver (with window resize fallback), and conditional “See more / See less” toggle; replaced clamped <p> with this component and switched desktop scroll container to explicit thin scrollbar styling.
Dialog Skeleton Styling
components/brain/left-sidebar/waves/memes-quick-vote/MemesQuickVoteDialogSkeleton.tsx
Replaced various border/background utilities with unified iron palette classes and reduced some skeleton opacity values; removed several border-related utility classes.
Drop media minor fixes
components/drops/view/item/content/media/DropListItemContentMedia.tsx, components/drops/view/item/content/media/DropListItemContentMediaImage.tsx
Changed default branch to return assertUnreachable(mediaType); removed inline fallback comment; added void before requestFullscreen() to ignore returned promise; added eslint-disable for raw <img> to silence Next.js linting.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Suggested reviewers

  • simo6529
  • prxt6529

Poem

🐰
I measured lines beneath my paws,
A toggle sprung from careful laws.
Scrollbars slim and colors named iron,
Tiny fixes hopped in, not lyin’ —
A happy ripple, quick-vote cheers! 🎟️

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'see more btn and media loading' is partially related to the changeset. It accurately captures the 'See more/See less' toggle button addition in MemesQuickVoteDescription, but incompletely describes the media-related changes (scrollbar styling update, fallback comment removal, fullscreen promise handling) which comprise a significant portion of the actual changes.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch quick-vote-modal-fixes

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
components/drops/view/item/content/media/DropListItemContentMediaImage.tsx (1)

66-78: ⚠️ Potential issue | 🟠 Major

Guard against duplicate retry timers in handleError.

onError can fire more than once before errorCount updates. This can queue multiple timers and move errorCount past maxRetries without setting hasFailed, which can leave the component blank (no image, no placeholder, no failure UI).

💡 Proposed fix
-import React, { useCallback, useRef, useState } from "react";
+import React, { useCallback, useEffect, useRef, useState } from "react";
@@
   const [errorCount, setErrorCount] = useState(0);
   const [retryTick, setRetryTick] = useState(0);
+  const retryTimerRef = useRef<number | null>(null);
@@
   const handleError = useCallback(() => {
+    if (retryTimerRef.current !== null) {
+      return;
+    }
+
     if (errorCount >= maxRetries) {
       setHasFailed(true);
       setLoaded(false);
       return;
     }
 
     const delay = 500 * 2 ** errorCount; // 0.5s, 1s, 2s …
-    setTimeout(() => {
+    retryTimerRef.current = window.setTimeout(() => {
+      retryTimerRef.current = null;
       setErrorCount((n) => n + 1);
       setRetryTick((t) => t + 1); // changes key -> reload
     }, delay);
   }, [errorCount, maxRetries]);
+
+  useEffect(() => {
+    return () => {
+      if (retryTimerRef.current !== null) {
+        window.clearTimeout(retryTimerRef.current);
+      }
+    };
+  }, []);
@@
   const manualRetry = () => {
+    if (retryTimerRef.current !== null) {
+      window.clearTimeout(retryTimerRef.current);
+      retryTimerRef.current = null;
+    }
     setErrorCount(0);
     setHasFailed(false);
     setLoaded(false);
     setRetryTick((t) => t + 1);
   };
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@components/drops/view/item/content/media/DropListItemContentMediaImage.tsx`
around lines 66 - 78, handleError can schedule multiple overlapping timers
because onError may fire before errorCount updates; prevent duplicate retries by
adding a ref (e.g., retryTimerRef) to track the pending timeout and skip
scheduling if it exists, and clear/reset that ref when the timer runs or on
unmount. Update handleError (and its dependency list) to: check
retryTimerRef.current and return early if set; compute whether the next error
would exceed maxRetries and immediately setHasFailed/setLoaded if so; otherwise
set retryTimerRef.current = setTimeout(() => { setErrorCount(n => n + 1);
setRetryTick(t => t + 1); retryTimerRef.current = null }, delay). Also add a
cleanup useEffect to clearTimeout(retryTimerRef.current) on unmount and clear
the ref when an image loads successfully.
🧹 Nitpick comments (1)
components/brain/left-sidebar/waves/memes-quick-vote/MemesQuickVoteControls.tsx (1)

79-108: Consider debouncing ResizeObserver callbacks for performance.

The ResizeObserver callback fires on every resize event, which could trigger multiple measureOverflow calls in rapid succession during continuous resizing (e.g., window resize, dynamic content changes). While React batches state updates, debouncing could reduce unnecessary layout measurements.

♻️ Optional: Add debouncing to ResizeObserver
   useEffect(() => {
     const frameId = globalThis.requestAnimationFrame(() => {
       measureOverflow();
     });

     if (typeof ResizeObserver === "undefined") {
       const handleResize = () => {
         measureOverflow();
       };

       globalThis.addEventListener("resize", handleResize);
       return () => {
         globalThis.removeEventListener("resize", handleResize);
         globalThis.cancelAnimationFrame(frameId);
       };
     }

+    let resizeFrameId: number | null = null;
     const observer = new ResizeObserver(() => {
-      measureOverflow();
+      if (resizeFrameId !== null) {
+        globalThis.cancelAnimationFrame(resizeFrameId);
+      }
+      resizeFrameId = globalThis.requestAnimationFrame(() => {
+        measureOverflow();
+        resizeFrameId = null;
+      });
     });

     if (visibleDescriptionRef.current) {
       observer.observe(visibleDescriptionRef.current);
     }

     return () => {
       observer.disconnect();
       globalThis.cancelAnimationFrame(frameId);
+      if (resizeFrameId !== null) {
+        globalThis.cancelAnimationFrame(resizeFrameId);
+      }
     };
   }, [measureOverflow]);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@components/brain/left-sidebar/waves/memes-quick-vote/MemesQuickVoteControls.tsx`
around lines 79 - 108, The ResizeObserver callback in the useEffect for
MemesQuickVoteControls can fire rapidly and should be debounced: create a
debounced wrapper around measureOverflow (e.g., using a timeoutId stored in a
ref like resizeTimeoutRef) and replace direct calls to measureOverflow in the
ResizeObserver callback and in handleResize with calls to that debounced
wrapper; ensure the cleanup clears the timeout (clearTimeout on
resizeTimeoutRef.current), disconnects the observer, removes the resize event
listener, and cancels the initial requestAnimationFrame (frameId) so no stray
timers or observers remain; keep measureOverflow and visibleDescriptionRef usage
unchanged but call them only from the debounced function.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@components/drops/view/item/content/media/DropListItemContentMedia.tsx`:
- Around line 89-110: The MIME checks in DropListItemContentMedia (using
media_mime_type -> normalizedMimeType) don't strip MIME parameters, so values
like "text/html; charset=utf-8" fall through; update the logic in the function
that computes normalizedMimeType to first remove any parameters (e.g., split on
';' and take the first part, then trim().toLowerCase()) before performing the
includes/equals checks for MediaType. Ensure the same normalized,
parameter-stripped value is used for the image/video/audio/model/gltf and
text/html comparisons and only call resolveMediaTypeFromUrl(media_url) as the
final fallback.

---

Outside diff comments:
In `@components/drops/view/item/content/media/DropListItemContentMediaImage.tsx`:
- Around line 66-78: handleError can schedule multiple overlapping timers
because onError may fire before errorCount updates; prevent duplicate retries by
adding a ref (e.g., retryTimerRef) to track the pending timeout and skip
scheduling if it exists, and clear/reset that ref when the timer runs or on
unmount. Update handleError (and its dependency list) to: check
retryTimerRef.current and return early if set; compute whether the next error
would exceed maxRetries and immediately setHasFailed/setLoaded if so; otherwise
set retryTimerRef.current = setTimeout(() => { setErrorCount(n => n + 1);
setRetryTick(t => t + 1); retryTimerRef.current = null }, delay). Also add a
cleanup useEffect to clearTimeout(retryTimerRef.current) on unmount and clear
the ref when an image loads successfully.

---

Nitpick comments:
In
`@components/brain/left-sidebar/waves/memes-quick-vote/MemesQuickVoteControls.tsx`:
- Around line 79-108: The ResizeObserver callback in the useEffect for
MemesQuickVoteControls can fire rapidly and should be debounced: create a
debounced wrapper around measureOverflow (e.g., using a timeoutId stored in a
ref like resizeTimeoutRef) and replace direct calls to measureOverflow in the
ResizeObserver callback and in handleResize with calls to that debounced
wrapper; ensure the cleanup clears the timeout (clearTimeout on
resizeTimeoutRef.current), disconnects the observer, removes the resize event
listener, and cancels the initial requestAnimationFrame (frameId) so no stray
timers or observers remain; keep measureOverflow and visibleDescriptionRef usage
unchanged but call them only from the debounced function.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e2889645-3485-4c45-9f90-1aa35890c1df

📥 Commits

Reviewing files that changed from the base of the PR and between e7b9e45 and b335575.

📒 Files selected for processing (4)
  • components/brain/left-sidebar/waves/memes-quick-vote/MemesQuickVoteControls.tsx
  • components/brain/left-sidebar/waves/memes-quick-vote/MemesQuickVoteDialogSkeleton.tsx
  • components/drops/view/item/content/media/DropListItemContentMedia.tsx
  • components/drops/view/item/content/media/DropListItemContentMediaImage.tsx

Comment thread components/drops/view/item/content/media/DropListItemContentMedia.tsx Outdated
ragnep added 2 commits March 27, 2026 12:03
Signed-off-by: ragnep <ragneinfo@gmail.com>
Signed-off-by: ragnep <ragneinfo@gmail.com>
@sonarqubecloud
Copy link
Copy Markdown

@ragnep ragnep merged commit bb3de47 into main Mar 27, 2026
8 checks passed
@ragnep ragnep deleted the quick-vote-modal-fixes branch March 27, 2026 10:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants