mirror of
https://github.com/HeyPuter/puter.git
synced 2026-08-27 16:37:18 +00:00
Only remove stale rows when moving items
This commit is contained in:
@@ -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 ) {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user