mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-23 14:36:24 +00:00
dots-viewer: Remove containing div when removing last dot file from a folder
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8521>
This commit is contained in:
parent
0155655854
commit
ce912c6320
2 changed files with 22 additions and 11 deletions
|
@ -304,17 +304,18 @@ impl GstDots {
|
|||
let path = path.to_path_buf();
|
||||
let clients = app_clone.viewer_clients.lock().unwrap();
|
||||
let clients = clients.clone();
|
||||
|
||||
for client in clients.iter() {
|
||||
debug!("Sending to client: {:?}", client);
|
||||
client.do_send(TextMessage(
|
||||
let path = path.to_path_buf();
|
||||
let name = app_clone.relative_dot_path(&path);
|
||||
let value =
|
||||
json!({
|
||||
"type": "DotRemoved",
|
||||
"name": path.file_name().unwrap().to_str().unwrap(),
|
||||
"creation_time": app_clone.modify_time(&event.paths[0]),
|
||||
})
|
||||
.to_string(),
|
||||
));
|
||||
"name": name,
|
||||
"creation_time": app_clone.modify_time(&path),
|
||||
});
|
||||
|
||||
for client in clients.iter() {
|
||||
debug!("Sending {value:?} to client: {client:?}");
|
||||
client.do_send(TextMessage(value.to_string()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -214,11 +214,21 @@ export function connectWs() {
|
|||
updateSearch();
|
||||
});
|
||||
} else if (obj.type == "DotRemoved") {
|
||||
console.debug(`Trying to remove: ${obj.name}`);
|
||||
let dot_id = dotId(obj);
|
||||
let dot_div = document.getElementById(dot_id);
|
||||
if (dot_div) {
|
||||
console.info(`Removing dot_div ${dot_id}`);
|
||||
dot_div.remove();
|
||||
let parent = dot_div.parentElement;
|
||||
if (obj.name.includes('/') && parent.childElementCount == 1) {
|
||||
console.info(`Last element in folder, removing parent div for ${dot_id}`);
|
||||
const wrapperDiv = parent.closest('.wrap-collabsible');
|
||||
if (wrapperDiv) {
|
||||
wrapperDiv.remove();
|
||||
}
|
||||
} else {
|
||||
console.info(`Removing dot_div ${dot_id}`);
|
||||
dot_div.remove();
|
||||
}
|
||||
} else {
|
||||
console.error(`dot_div ${dot_id} not found`);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue