feat: added user list in the treeview

This commit is contained in:
frelodev 2024-09-16 22:42:37 +02:00
parent 03baabfae6
commit 2e62362ff3

View file

@ -1,6 +1,6 @@
import * as vscode from 'vscode'; import * as vscode from 'vscode';
import { client, workspace, workspace_list } from './commands'; import { client, workspace, workspace_list } from './commands';
import { bufferMapper } from './mapping'; import { bufferMapper, colors_cache } from './mapping';
export class CodempTreeProvider implements vscode.TreeDataProvider<CodempTreeItem> { export class CodempTreeProvider implements vscode.TreeDataProvider<CodempTreeItem> {
@ -23,34 +23,35 @@ export class CodempTreeProvider implements vscode.TreeDataProvider<CodempTreeIte
case Type.Workspace: case Type.Workspace:
if (workspace === null) { return [] }; if (workspace === null) { return [] };
if (element.label == workspace.id()) { if (element.label == workspace.id()) {
// return [
// new CodempTreeItem("Buffers", Type.BufferContainer, true),
// new CodempTreeItem("Users", Type.UserContainer, true)
// ];
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, false, bufferMapper.bufferToEditorMapping.has(x))
); );
} else { } else {
return []; return [];
} }
case Type.BufferContainer:
if (workspace === null) { return [] }; case Type.UserList:
return workspace.filetree(undefined, false).map((x) => let out = [];
new CodempTreeItem(x, Type.Buffer, false, bufferMapper.bufferToEditorMapping.has(x)) for (let x of colors_cache.keys()){
); out.push(new CodempTreeItem(x, Type.User, false));
case Type.UserContainer: };
if (workspace === null) { return [] }; return out;
return [new CodempTreeItem("TODO", Type.User, false)]; // TODO keep track of users
case Type.Buffer: case Type.Buffer:
return []; return [];
case Type.User: case Type.User:
return []; return [];
} }
return [];
} else { } else {
if(client === null) return []; if(client === null) {
return workspace_list.map((x) => return [];
}
let items = workspace_list.map((x) =>
new CodempTreeItem(x, Type.Workspace, true, workspace !== null && workspace.id() == x) new CodempTreeItem(x, Type.Workspace, true, workspace !== null && workspace.id() == x)
); );
items.push(new CodempTreeItem("", Type.Placeholder, false));
items.push(new CodempTreeItem("<Users>", Type.UserList, true));
return items;
} }
} }
} }
@ -71,8 +72,8 @@ class CodempTreeItem extends vscode.TreeItem {
enum Type { enum Type {
Workspace = "workspace", Workspace = "workspace",
BufferContainer = "container_buffer", UserList = "user_list",
UserContainer = "container_user",
Buffer = "buffer", Buffer = "buffer",
User = "user", User = "user",
Placeholder = "placeholder"
} }