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 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 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 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 = native.connect(host, username, password):await()
session.client = client window.update()
window.update() vim.schedule(function () workspace.list() end)
print(" ++ connected to " .. host .. " as " .. username)
vim.schedule(function () workspace.list(client) end)
end)
end end
return { return {

View file

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