Only remove stale rows when moving items

This commit is contained in:
jelveh
2026-07-16 17:52:48 -07:00
parent 67f8f0f5f5
commit ea063c7413
2 changed files with 17 additions and 6 deletions
+11 -4
View File
@@ -266,10 +266,17 @@ async function UIDashboard (options) {
window.socket.on('item.moved', async (resp) => {
if ( resp.original_client_socket_id === window.socket.id ) return;
// Fade out old item from view
$(`.item[data-uid='${resp.uid}']`).fadeOut(150, function () {
$(this).remove();
});
// Fade out the stale row at the item's OLD location only. A moved item
// keeps its uid, so removing by uid would also match the row at the new
// location — and when the destination is the directory currently in
// view (e.g. after spring-loading a folder open mid-drag), that deletes
// the freshly-added row instead of the stale one.
const old_path = resp.old_path ?? resp.from_path;
if ( old_path ) {
$(`.item[data-path='${html_encode(old_path)}']`).fadeOut(150, function () {
$(this).remove();
});
}
// Create new item at destination if user is viewing that directory
if ( window.UIDashboardFileItem ) {
+6 -2
View File
@@ -1817,8 +1817,12 @@ window.move_items = async function (el_items, dest_path, is_undo = false) {
// update all shortcut_to_path
$(`.item[data-shortcut_to_path="${html_encode($(el_item).attr('data-path'))}" i]`).attr('data-shortcut_to_path', fsentry.path);
// Remove all items with matching uids
$(`.item[data-uid='${$(el_item).attr('data-uid')}']`).fadeOut(150, function () {
// Remove all items with matching uids from their OLD location(s).
// Exclude any row already at the item's new path: a concurrent
// item.moved socket handler may have just created a row at the
// destination (e.g. the dashboard file view showing the target
// directory), and removing by uid alone would delete it too.
$(`.item[data-uid='${$(el_item).attr('data-uid')}']`).not(`[data-path="${html_encode(fsentry.path)}" i]`).fadeOut(150, function () {
// find all parent windows that contain this item
let parent_windows = $(`.item[data-uid='${$(el_item).attr('data-uid')}']`).closest('.window');
// remove this item