[READ-ONLY] Mirror of https://github.com/probablykasper/ferrum. Music library app for Mac, Linux and Windows ferrum.kasper.space
electron linux macos music music-library music-player napi windows
0

Configure Feed

Select the types of activity you want to include in your feed.

Disable rearranging when filter is on

Kasper (May 14, 2021, 9:49 AM +0200) 1df02816 7836e860

+13 -9
+3
native/src/page.rs
··· 165 165 if data.sort_key != "index" || data.sort_desc != true { 166 166 return Err(nerr!("Cannot rearrange when custom sorting is used")); 167 167 } 168 + if data.filter != "" { 169 + return Err(nerr!("Cannot rearrange when filter is used")); 170 + } 168 171 let playlist = match tracklist { 169 172 TrackList::Playlist(playlist) => playlist, 170 173 TrackList::Folder(_) => return Err(nerr!("Cannot rearrange tracks in folder")),
+10 -9
src/components/TrackList.svelte
··· 1 1 <script lang="ts"> 2 2 import VList from './VirtualList.svelte' 3 - import { page, removeFromOpenPlaylist } from '../stores/data' 3 + import { page, removeFromOpenPlaylist, filter } from '../stores/data' 4 4 import { newPlaybackInstance, playingId } from '../stores/player' 5 5 import { getDuration, formatDate, checkMouseShortcut } from '../scripts/helpers' 6 6 import { showTrackMenu } from '../stores/contextMenu' ··· 98 98 let dragging = false 99 99 let indexes: number[] = [] 100 100 function onDragStart(e: DragEvent) { 101 - indexes = [] 102 - for (let i = 0; i < $selection.list.length; i++) { 103 - if ($selection.list[i]) { 104 - indexes.push(i) 101 + if (e.dataTransfer) { 102 + indexes = [] 103 + for (let i = 0; i < $selection.list.length; i++) { 104 + if ($selection.list[i]) { 105 + indexes.push(i) 106 + } 105 107 } 106 - } 107 - if (e.dataTransfer) { 108 108 dragging = true 109 109 e.dataTransfer.effectAllowed = 'move' 110 110 if (indexes.length === 1) { ··· 119 119 } 120 120 onMount(() => { 121 121 function dragOverHandler(e: DragEvent) { 122 - if (dragging && e.dataTransfer && e.dataTransfer.types[0] === 'ferrumtracks') { 122 + if (dragging) { 123 123 e.preventDefault() 124 124 } 125 125 } ··· 128 128 }) 129 129 let dragToIndex: null | number = null 130 130 function onDragOver(e: DragEvent, index: number) { 131 - if (!$page.sort_desc || $page.sort_key !== 'index') { 131 + if (!$page.sort_desc || $page.sort_key !== 'index' || $filter) { 132 132 dragToIndex = null 133 133 return 134 134 } ··· 152 152 function dragEndHandler() { 153 153 dragging = false 154 154 if (dragToIndex !== null) { 155 + console.log(indexes, dragToIndex) 155 156 const newSelection = page.moveTracks(indexes, dragToIndex) 156 157 for (let i = newSelection.from; i <= newSelection.to; i++) { 157 158 selection.add(i)