fix: dont use and_then yet

This commit is contained in:
əlemi 2024-09-01 03:06:27 +02:00
parent 237e3fc619
commit 87dcb03b51
Signed by: alemi
GPG key ID: A4895B84D311642C
2 changed files with 19 additions and 24 deletions

View file

@ -7,12 +7,9 @@ local function connect(host, username, password)
if host == nil then host = 'http://codemp.dev:50053' end
if username == nil then username = vim.g.codemp_username or vim.fn.input("username > ", "") end
if password == nil then password = vim.g.codemp_password or vim.fn.input("password > ", "") end
native.connect(host, username, password):and_then(function (client)
session.client = client
window.update()
print(" ++ connected to " .. host .. " as " .. username)
vim.schedule(function () workspace.list(client) end)
end)
session.client = native.connect(host, username, password):await()
window.update()
vim.schedule(function () workspace.list() end)
end
return {

View file

@ -7,24 +7,22 @@ local user_hl = {}
local function fetch_workspaces_list()
local new_list = {}
session.client:list_workspaces(true, false):and_then(function (owned)
for _, ws in pairs(owned) do
table.insert(new_list, {
name = ws,
owned = true,
})
end
session.client:list_workspaces(false, true):and_then(function (invited)
for _, ws in pairs(invited) do
table.insert(new_list, {
name = ws,
owned = false,
})
end
session.available = new_list
window.update()
end)
end)
local owned = session.client:list_workspaces(true, false):await()
for _, ws in pairs(owned) do
table.insert(new_list, {
name = ws,
owned = true,
})
end
local invited = session.client:list_workspaces(false, true):await()
for _, ws in pairs(invited) do
table.insert(new_list, {
name = ws,
owned = false,
})
end
session.available = new_list
window.update()
end
---@param ws Workspace