mirror of
https://github.com/hexedtech/codemp-vscode.git
synced 2024-11-25 08:54:48 +01:00
fix: dont fetch remote workspaces every time
what was this spaghetti mess!!!!!!!
This commit is contained in:
parent
31a84b1ab4
commit
d65f6c0c34
1 changed files with 17 additions and 32 deletions
49
src/tree.ts
49
src/tree.ts
|
@ -21,56 +21,41 @@ export class CodempTreeProvider implements vscode.TreeDataProvider<CodempTreeIte
|
||||||
if (element) {
|
if (element) {
|
||||||
switch (element.type) {
|
switch (element.type) {
|
||||||
case Type.Workspace:
|
case Type.Workspace:
|
||||||
if(client === null) {
|
if (workspace === null) return [];
|
||||||
return [];
|
else if (element.label == workspace.id()) {
|
||||||
}
|
|
||||||
if (workspace === null) { return [] };
|
|
||||||
let workspaces= await client.list_workspaces(true,true);
|
|
||||||
if(workspaces.length===0) {
|
|
||||||
let out = [];
|
|
||||||
out.push(new CodempTreeItem("No workspaces", Type.Placeholder, false));
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
if (element.label == workspace.id()) {
|
|
||||||
return workspace.filetree(undefined, false).map((x) =>
|
return workspace.filetree(undefined, false).map((x) =>
|
||||||
new CodempTreeItem(x, Type.Buffer, false, bufferMapper.bufferToEditorMapping.has(x))
|
new CodempTreeItem(x, Type.Buffer, { active: bufferMapper.bufferToEditorMapping.has(x) })
|
||||||
);
|
);
|
||||||
} else {
|
} else return [];
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
case Type.UserList:
|
case Type.UserList:
|
||||||
let out = [];
|
let out = [];
|
||||||
|
|
||||||
/*colors_cache.forEach(function(x){
|
|
||||||
out.push(new CodempTreeItem(x.color, Type.User, false));
|
|
||||||
});*/
|
|
||||||
for (let x of colors_cache){
|
for (let x of colors_cache){
|
||||||
|
out.push(new CodempTreeItem(x[0], Type.User, { description: x[1].buffer }));
|
||||||
out.push(new CodempTreeItem(`${x[0]} (${x[1].buffer})`, Type.User, false));
|
|
||||||
};
|
};
|
||||||
return out;
|
return out;
|
||||||
|
|
||||||
case Type.Buffer:
|
case Type.Buffer:
|
||||||
return [];
|
return [];
|
||||||
|
|
||||||
case Type.User:
|
case Type.User:
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
return [];
|
return [];
|
||||||
} else {
|
} else {
|
||||||
if(client === null) {
|
if (client === null) {
|
||||||
return [];
|
return []; // empty screen with [connect] button
|
||||||
}
|
|
||||||
let workspaces= await client.list_workspaces(true,true);
|
|
||||||
if(workspaces.length===0) {
|
|
||||||
let out = [];
|
|
||||||
out.push(new CodempTreeItem("No workspaces", Type.Placeholder, false));
|
|
||||||
return out;
|
|
||||||
}
|
}
|
||||||
let items = workspace_list.map((x) =>
|
let items = workspace_list.map((x) =>
|
||||||
new CodempTreeItem(x, Type.Workspace, true, workspace === null)
|
new CodempTreeItem(x, Type.Workspace, { expandable: true, active: workspace === null})
|
||||||
);
|
);
|
||||||
items.push(new CodempTreeItem("", Type.Placeholder, false));
|
if (workspace !== null) {
|
||||||
items.push(new CodempTreeItem("Users", Type.UserList, true));
|
items.push(new CodempTreeItem("", Type.Placeholder, {}));
|
||||||
|
items.push(new CodempTreeItem("Users", Type.UserList, { expandable: true }));
|
||||||
|
}
|
||||||
|
if (items.length == 0) {
|
||||||
|
items.push(new CodempTreeItem("No workspaces", Type.Placeholder, {}));
|
||||||
|
}
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue