Skip to content

Commit

Permalink
Handle remove directory action
Browse files Browse the repository at this point in the history
  • Loading branch information
thang.tranxuan committed May 22, 2023
1 parent e7dd9d8 commit 0a74f79
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
2 changes: 2 additions & 0 deletions src-tauri/src/library.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ pub fn initialize_library(conn: &Connection) -> Result<()> {
return Ok(())
}

db::clean_library(conn)?;

let directories = db::get_directories(conn)?;
let tracks = fs_track::load_tracks_from_directories(&directories)?;
let result = add_tracks(tracks, conn);
Expand Down
11 changes: 9 additions & 2 deletions src/components/ChooseDirectory.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
<div class="grow flex flex-col items-center justify-center gap-8 w-full max-w-screen-sm">
<div class="flex flex-col gap-2 w-full justify-center items-center">
<div
v-for="directory in directories"
v-for="(directory, index) in directories"
:key="directory"
class="w-full bg-brave-99 text-brave-5 font-bold p-4 rounded-lg flex items-center"
>
<div class="grow">
{{ directory }}
</div>
<button class="flex-none text-white bg-gray-700 hover:bg-gray-600 active:bg-gray-800 p-1 flex justify-center items-center rounded-full" @click.prevent="removeDirectory(directory)">
<button class="flex-none text-white bg-gray-700 hover:bg-gray-600 active:bg-gray-800 p-1 flex justify-center items-center rounded-full" @click.prevent="removeDirectory(index)">
<Close />
</button>
</div>
Expand Down Expand Up @@ -79,4 +79,11 @@ const chooseDirectory = async () => {
directories.value.push(selected)
}
}
const removeDirectory = (index) => {
if (index < 0) {
return
}
directories.value.splice(index)
}
</script>
14 changes: 7 additions & 7 deletions src/components/library/Config.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
</div>
</div>

<div>
<label class="group-label mb-2">Experimental</label>
<!-- <div>
<label class="group-label mb-2">Experimental</label>
<div class="flex items-center">
<input id="try-embed-lyrics" type="checkbox" v-model="tryEmbedLyrics" class="checkbox">
<label for="try-embed-lyrics" class="checkbox-label ml-2">Try to embed the lyrics to the track files when possible</label>
</div>
</div>
<div class="flex items-center">
<input id="try-embed-lyrics" type="checkbox" v-model="tryEmbedLyrics" class="checkbox">
<label for="try-embed-lyrics" class="checkbox-label ml-2">Try to embed the lyrics to the track files when possible</label>
</div>
</div> -->
</div>
<div class="flex flex-col gap-1">
<a href="#" class="link" @click="refreshLibrary">Refresh my library for new changes...</a>
Expand Down

0 comments on commit 0a74f79

Please sign in to comment.