diff --git a/app/templates/gitea_workspace.html b/app/templates/gitea_workspace.html index c77a004..46f49ab 100644 --- a/app/templates/gitea_workspace.html +++ b/app/templates/gitea_workspace.html @@ -215,14 +215,15 @@ function giteaWorkspace() { commitHistory: JSON.parse(localStorage.getItem('fd_commit_msgs') || '[]'), // File tree browser treeItems: [], + sortedTreeItems: [], treeLoading: false, folderStack: [], currentPath: '', // Context menu gwCtx: { visible: false, x: 0, y: 0, item: null }, - get sortedTreeItems() { - return [...this.treeItems].sort(function(a, b) { + _sortTree() { + this.sortedTreeItems = [...this.treeItems].sort(function(a, b) { if (a.type === b.type) return a.name.localeCompare(b.name); return a.type === 'folder' ? -1 : 1; }); @@ -248,10 +249,11 @@ function giteaWorkspace() { var url = '/api/gitea/projects/' + this.owner + '/' + this.repo + '/tree'; if (path) url += '?path=' + encodeURIComponent(path); var r = await fetch(url); - if (!r.ok) { this.treeItems = []; return; } + if (!r.ok) { this.treeItems = []; this.sortedTreeItems = []; return; } var d = await r.json(); this.treeItems = d.tree || []; - } catch(e) { this.treeItems = []; } + this._sortTree(); + } catch(e) { this.treeItems = []; this.sortedTreeItems = []; } finally { this.treeLoading = false; } },