fix: Add and remove dropdown entries dynamically

This commit is contained in:
Fabio Lenherr / DashieTM 2023-11-19 17:57:11 +01:00
parent cb3dd257f1
commit b68bc0ab77
3 changed files with 31 additions and 20 deletions

View file

@ -1,17 +1,4 @@
[
{
"type": "archive",
"archive-type": "tar-gzip",
"url": "https://static.crates.io/crates/ReSet-Lib/ReSet-Lib-0.2.8.crate",
"sha256": "6761097b3d41653f8ad3b265625c840b6c415282ba20a0491fe6a7a7e817873a",
"dest": "cargo/vendor/ReSet-Lib-0.2.8"
},
{
"type": "inline",
"contents": "{\"package\": \"6761097b3d41653f8ad3b265625c840b6c415282ba20a0491fe6a7a7e817873a\", \"files\": {}}",
"dest": "cargo/vendor/ReSet-Lib-0.2.8",
"dest-filename": ".cargo-checksum.json"
},
{
"type": "archive",
"archive-type": "tar-gzip",
@ -1055,14 +1042,14 @@
{
"type": "archive",
"archive-type": "tar-gzip",
"url": "https://static.crates.io/crates/reset_daemon/reset_daemon-0.1.8.crate",
"sha256": "a861e230340e001757325a01fa33cfce9e29111f0228dd2abd1d62206f742803",
"dest": "cargo/vendor/reset_daemon-0.1.8"
"url": "https://static.crates.io/crates/reset_daemon/reset_daemon-0.1.9.crate",
"sha256": "ff35f2cbd703c80a77a53458e7a3c32ccba9c73b7b8ce65924cdbe291d960f58",
"dest": "cargo/vendor/reset_daemon-0.1.9"
},
{
"type": "inline",
"contents": "{\"package\": \"a861e230340e001757325a01fa33cfce9e29111f0228dd2abd1d62206f742803\", \"files\": {}}",
"dest": "cargo/vendor/reset_daemon-0.1.8",
"contents": "{\"package\": \"ff35f2cbd703c80a77a53458e7a3c32ccba9c73b7b8ce65924cdbe291d960f58\", \"files\": {}}",
"dest": "cargo/vendor/reset_daemon-0.1.9",
"dest-filename": ".cargo-checksum.json"
},
{

View file

@ -361,6 +361,11 @@ pub fn start_input_box_listener(conn: Connection, source_box: Arc<SourceBox>) ->
output_box_imp.resetSources.append(&*entry);
let mut map = output_box_imp.resetSourceMap.write().unwrap();
let mut index = output_box_imp.resetModelIndex.write().unwrap();
output_box_imp
.resetModelList
.write()
.unwrap()
.append(&alias);
map.insert(alias, (source_index, *index, name));
*index += 1;
});
@ -391,7 +396,14 @@ pub fn start_input_box_listener(conn: Connection, source_box: Arc<SourceBox>) ->
return;
}
let mut map = output_box_imp.resetSourceMap.write().unwrap();
map.remove(&alias.unwrap().2);
let entry_index = map.remove(&alias.unwrap().2);
if entry_index.is_some() {
output_box_imp
.resetModelList
.write()
.unwrap()
.remove(entry_index.unwrap().1);
}
let mut index = output_box_imp.resetModelIndex.write().unwrap();
if *index != 0 {
*index -= 1;

View file

@ -365,6 +365,11 @@ pub fn start_output_box_listener(conn: Connection, sink_box: Arc<SinkBox>) -> Co
output_box_imp.resetSinks.append(&*entry);
let mut map = output_box_imp.resetSinkMap.write().unwrap();
let mut index = output_box_imp.resetModelIndex.write().unwrap();
output_box_imp
.resetModelList
.write()
.unwrap()
.append(&alias);
map.insert(alias, (sink_index, *index, name));
*index += 1;
});
@ -393,7 +398,14 @@ pub fn start_output_box_listener(conn: Connection, sink_box: Arc<SinkBox>) -> Co
return;
}
let mut map = output_box_imp.resetSinkMap.write().unwrap();
map.remove(&alias.unwrap().2);
let entry_index = map.remove(&alias.unwrap().2);
if entry_index.is_some() {
output_box_imp
.resetModelList
.write()
.unwrap()
.remove(entry_index.unwrap().1);
}
let mut index = output_box_imp.resetModelIndex.write().unwrap();
if *index != 0 {
*index -= 1;