Skip to content

Commit

Permalink
fix bug in clickpackdb
Browse files Browse the repository at this point in the history
  • Loading branch information
zeozeozeo committed Mar 19, 2024
1 parent 482726d commit 7306216
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "zcb3"
version = "3.4.8"
version = "3.4.9"
edition = "2021"
authors = ["zeozeozeo"]
build = "build.rs"
Expand Down
17 changes: 13 additions & 4 deletions egui_clickpack_db/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const DATABASE_URL: &str = "https://raw.githubusercontent.com/zeozeozeo/clickpac
type RequestFn = dyn Fn(&str) -> Result<Vec<u8>, String> + Sync;
type PickFolderFn = dyn Fn() -> Option<PathBuf> + Sync;

#[derive(Clone, Default)]
#[derive(Clone, Default, Debug)]
enum DownloadStatus {
#[default]
NotDownloaded,
Expand Down Expand Up @@ -366,9 +366,10 @@ impl ClickpackDb {
row_index: usize,
pick_folder: &'static PickFolderFn,
) {
let set_status = |entries: &mut IndexMap<String, Entry>, status: DownloadStatus| {
entries.get_index_mut(row_index).unwrap().1.dwn_status = status;
};
let set_status =
|entries: &mut IndexMap<String, Entry>, name: &str, status: DownloadStatus| {
entries.get_mut(name).unwrap().dwn_status = status;
};

ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
ui.add_space(14.0);
Expand All @@ -383,6 +384,7 @@ impl ClickpackDb {
if let Some(path) = pick_folder() {
set_status(
&mut self.db.write().unwrap().entries,
&name,
DownloadStatus::Downloading,
);
self.update_filtered_entries();
Expand All @@ -396,6 +398,7 @@ impl ClickpackDb {
{
set_status(
&mut self.db.write().unwrap().entries,
&name,
DownloadStatus::Downloading,
);
self.update_filtered_entries();
Expand Down Expand Up @@ -435,13 +438,19 @@ impl ClickpackDb {
if do_select {
set_status(
&mut self.db.write().unwrap().entries,
&name,
DownloadStatus::Downloaded {
path: path.clone(),
do_select: false,
},
);
self.update_filtered_entries();
log::info!(
"dwn status: {:?}",
self.filtered_entries[row_index].dwn_status
);
}
log::info!("selecting clickpack {path:?}");
self.select_clickpack = Some(path.clone());
}
}
Expand Down

0 comments on commit 7306216

Please sign in to comment.