Kaynağa Gözat

move to top inserts after current top video

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Brandon Wong 2 hafta önce
ebeveyn
işleme
4401111325

+ 21 - 0
2026-06-10-claude-move-to-top-inserts-after-top.md

@@ -0,0 +1,21 @@
+# Session Report: Move "Move to Top" to insert after top
+
+## Request
+
+> in the popup main view, the menu has a "move to top" button, which brings the video to the "top" of the playlist. I would like to modify it to move it to the position after the top of the playlist.
+
+## Changes
+
+**File:** `popup/popup.js`
+
+Three targeted edits:
+
+1. **Insertion position** in `moveVideoToTop()`: changed `playlist.splice(topPosition, 0, video)` → `playlist.splice(topPosition + 1, 0, video)` so the video lands right *after* the current top video instead of displacing it.
+
+2. **Early-return guard** in `moveVideoToTop()`: updated `if (index === topPosition) return` → `if (index === topPosition + 1) return` to match the new target position.
+
+3. **Disabled binding** in `moveToTopButton`: changed `return index === topPosition` → `return index === topPosition + 1` so the button disables when the video is already at the 2nd (post-top) position.
+
+The button label "Move to Top" was kept as-is per user preference.
+
+The change applies to both the main playlists view and the individual playlist view since both share the same `moveToTopButton` binding and `moveVideoToTop()` function.

+ 3 - 3
popup/popup.js

@@ -622,10 +622,10 @@ document.addEventListener("alpine:init", () => {
 
       const topPosition = this.findTopPosition(playlistName);
 
-      if (index === topPosition) return;
+      if (index === topPosition + 1) return;
 
       const video = playlist.splice(index, 1)[0];
-      playlist.splice(topPosition, 0, video);
+      playlist.splice(topPosition + 1, 0, video);
 
       const updatedPlaylists = {
         ...playlists,
@@ -945,7 +945,7 @@ document.addEventListener("alpine:init", () => {
         const index = parseInt(this.$el.dataset.playlistIndex);
         const playlistName = this.$el.dataset.playlistName;
         const topPosition = this.findTopPosition(playlistName);
-        return index === topPosition;
+        return index === topPosition + 1;
       },
     },