From 87dcb03b51384768b683b89e758c6db602a6f3ea Mon Sep 17 00:00:00 2001 From: alemi Date: Sun, 1 Sep 2024 03:06:27 +0200 Subject: [PATCH] fix: dont use and_then yet --- src/client.lua | 9 +++------ src/workspace.lua | 34 ++++++++++++++++------------------ 2 files changed, 19 insertions(+), 24 deletions(-) diff --git a/src/client.lua b/src/client.lua index e5bd00d..b3d6f98 100644 --- a/src/client.lua +++ b/src/client.lua @@ -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 { diff --git a/src/workspace.lua b/src/workspace.lua index 2709afe..10d1690 100644 --- a/src/workspace.lua +++ b/src/workspace.lua @@ -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