refactor: consolidate navigation logic and improve refresh reliability using path data context
This commit is contained in:
@@ -1078,24 +1078,21 @@ class SharePointApp(wx.Frame):
|
|||||||
if idx < 0 or idx >= len(self.favorites): return
|
if idx < 0 or idx >= len(self.favorites): return
|
||||||
fav = self.favorites[idx]
|
fav = self.favorites[idx]
|
||||||
|
|
||||||
self.current_path = fav['path']
|
# Opret navigations-data fra favoritten
|
||||||
self.update_path_display()
|
|
||||||
|
|
||||||
# Navigate to contents
|
|
||||||
data = {
|
data = {
|
||||||
"type": fav['type'],
|
"type": fav['type'],
|
||||||
"id": fav['id'],
|
"id": fav['id'],
|
||||||
|
"name": fav['name'],
|
||||||
"drive_id": fav['drive_id'],
|
"drive_id": fav['drive_id'],
|
||||||
"path": fav['path']
|
"path": fav['path'],
|
||||||
|
"web_url": fav.get('web_url')
|
||||||
}
|
}
|
||||||
|
|
||||||
if fav['type'] == "SITE": self.current_site_id = fav['id']
|
# Vis indholdet og opdater stien
|
||||||
elif fav['drive_id']: self.current_drive_id = fav['drive_id']
|
self._navigate_to_item_data(data)
|
||||||
|
|
||||||
self.list_ctrl.DeleteAllItems()
|
# Forsøg at synkronisere træet asynkront
|
||||||
self.current_items = []
|
wx.CallAfter(self._sync_tree_selection_by_path, fav['path'])
|
||||||
self.set_status(self.get_txt("status_loading_content"))
|
|
||||||
threading.Thread(target=self._fetch_list_contents_bg, args=(data,), daemon=True).start()
|
|
||||||
|
|
||||||
def on_favorite_right_click(self, event):
|
def on_favorite_right_click(self, event):
|
||||||
idx = self.fav_list.GetFirstSelected()
|
idx = self.fav_list.GetFirstSelected()
|
||||||
@@ -1503,12 +1500,20 @@ class SharePointApp(wx.Frame):
|
|||||||
threading.Thread(target=self._fetch_tree_children_bg, args=(selected, data), daemon=True).start()
|
threading.Thread(target=self._fetch_tree_children_bg, args=(selected, data), daemon=True).start()
|
||||||
|
|
||||||
def _refresh_current_view(self):
|
def _refresh_current_view(self):
|
||||||
|
# 1. Prøv at bruge den aktuelle navigationskontekst (pålideligt ved Favorites/Breadcrumbs)
|
||||||
|
if hasattr(self, 'current_path_data') and self.current_path_data:
|
||||||
|
data = self.current_path_data[-1]
|
||||||
|
self.set_status(f"Opdaterer '{data['name']}'...")
|
||||||
|
threading.Thread(target=self._fetch_list_contents_bg, args=(data,), daemon=True).start()
|
||||||
|
return
|
||||||
|
|
||||||
|
# 2. Fallback til Træ-kontrol markering
|
||||||
sel = self.tree_ctrl.GetSelection()
|
sel = self.tree_ctrl.GetSelection()
|
||||||
if sel.IsOk():
|
if sel.IsOk():
|
||||||
data = self.tree_item_data.get(sel)
|
data = self.tree_item_data.get(sel)
|
||||||
if data:
|
if data:
|
||||||
# Kør i nuværende baggrundstråd hvis muligt, ellers ny
|
self.set_status(f"Opdaterer '{data['name']}'...")
|
||||||
self._fetch_list_contents_bg(data)
|
threading.Thread(target=self._fetch_list_contents_bg, args=(data,), daemon=True).start()
|
||||||
|
|
||||||
def clear_main(self):
|
def clear_main(self):
|
||||||
self.list_ctrl.DeleteAllItems()
|
self.list_ctrl.DeleteAllItems()
|
||||||
|
|||||||
Reference in New Issue
Block a user