diff --git a/src/gui/src/UI/UIDesktop.js b/src/gui/src/UI/UIDesktop.js index 2d41dc6e..eaef95b0 100644 --- a/src/gui/src/UI/UIDesktop.js +++ b/src/gui/src/UI/UIDesktop.js @@ -566,7 +566,13 @@ async function UIDesktop(options){ // load window sidebar items from KV puter.kv.get("sidebar_items").then(async (val) => { window.sidebar_items = val; - }) + }) + // also update every 2 seconds + setInterval(async () => { + puter.kv.get("sidebar_items").then(async (val) => { + window.sidebar_items = val; + }) + }, 2000); // Get menubar style puter.kv.get('menubar_style').then(async (val) => { diff --git a/src/gui/src/UI/UIWindow.js b/src/gui/src/UI/UIWindow.js index 26437f7b..f8cdf31a 100644 --- a/src/gui/src/UI/UIWindow.js +++ b/src/gui/src/UI/UIWindow.js @@ -2397,7 +2397,6 @@ async function UIWindow(options) { // Sidebar sortable //-------------------------------------------------- if(options.is_dir && !isMobile.phone){ - loadSavedSidebarOrder(el_window); const $sidebar = $(el_window).find('.window-sidebar'); $sidebar.sortable({ @@ -3678,35 +3677,4 @@ async function saveSidebarOrder(order) { } } -// Function to load and apply saved sidebar order -async function loadSavedSidebarOrder(el_window) { - setTimeout(async () => { - try { - // Load saved sidebar order - let savedOrder = window.sidebar_items - - // If not found in window object, try to get from KV - if(!savedOrder){ - savedOrder = await puter.kv.get("sidebar_items"); - } - - // If found, apply the order - if (savedOrder && savedOrder !== 'null' && savedOrder !== 'undefined') { - const order = JSON.parse(savedOrder); - const $sidebar = $(el_window).find('.window-sidebar'); - - // Reorder items according to saved order - order.forEach(item => { - const $item = $sidebar.find(`.window-sidebar-item[data-path="${item.path}"]`); - if ($item.length) { - $item.appendTo($sidebar); - } - }); - } - } catch(err) { - console.error('Error loading sidebar order:', err); - } -}, 1000); -} - export default UIWindow;