mirror of
https://github.com/jiriks74/presence.nvim
synced 2024-12-29 19:32:05 +01:00
parent
65a16b25f9
commit
774994a5b9
1 changed files with 9 additions and 2 deletions
|
@ -53,6 +53,7 @@ local Presence = {}
|
||||||
Presence.is_authorized = false
|
Presence.is_authorized = false
|
||||||
Presence.is_authorizing = false
|
Presence.is_authorizing = false
|
||||||
Presence.is_connected = false
|
Presence.is_connected = false
|
||||||
|
Presence.is_connecting = false
|
||||||
Presence.last_activity = {}
|
Presence.last_activity = {}
|
||||||
Presence.peers = {}
|
Presence.peers = {}
|
||||||
Presence.socket = vim.v.servername
|
Presence.socket = vim.v.servername
|
||||||
|
@ -238,7 +239,11 @@ end
|
||||||
function Presence:connect(on_done)
|
function Presence:connect(on_done)
|
||||||
self.log:debug("Connecting to Discord...")
|
self.log:debug("Connecting to Discord...")
|
||||||
|
|
||||||
|
self.is_connecting = true
|
||||||
|
|
||||||
self.discord:connect(function(err)
|
self.discord:connect(function(err)
|
||||||
|
self.is_connecting = false
|
||||||
|
|
||||||
-- Handle known connection errors
|
-- Handle known connection errors
|
||||||
if err == "EISCONN" then
|
if err == "EISCONN" then
|
||||||
self.log:info("Already connected to Discord")
|
self.log:info("Already connected to Discord")
|
||||||
|
@ -466,8 +471,10 @@ function Presence.discord_event(on_ready)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Schedule event if currently authorizing with Discord
|
-- Schedule event if currently authorizing with Discord
|
||||||
if self.is_authorizing then
|
if self.is_connecting or self.is_authorizing then
|
||||||
self.log:debug("Currently authorizing with Discord, scheduling callback for later...")
|
local action = self.is_connecting and "connecting" or "authorizing"
|
||||||
|
local message_fmt = "Currently %s with Discord, scheduling callback for later..."
|
||||||
|
self.log:debug(string.format(message_fmt, action))
|
||||||
return vim.schedule(callback)
|
return vim.schedule(callback)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue