Skip to content

Commit

Permalink
fix: should_skip_update should be checked right before the update
Browse files Browse the repository at this point in the history
  • Loading branch information
vyfor committed Dec 24, 2024
1 parent 8427bed commit 93636dd
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions lua/cord/activity/manager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,6 @@ end
---@param force_update? boolean Whether to force the update regardless of conditions
function ActivityManager:queue_update(force_update)
if not self.events_enabled then return end
if self.should_skip_update then
self.should_skip_update = false
return
end

self.opts = self:build_opts()
if not self.is_force_idle and (force_update or self:should_update()) then
Expand All @@ -156,10 +152,6 @@ function ActivityManager:check_idle()
if not self.events_enabled then return end
if not self.config.idle.enabled and not self.is_force_idle then return end
if self.is_idle then return end
if self.should_skip_update then
self.should_skip_update = false
return
end

local time_elapsed = uv.now() - self.last_updated
if
Expand Down Expand Up @@ -195,9 +187,20 @@ function ActivityManager:update_idle_activity()
self.config.hooks.on_idle(self.opts, activity)
end

if self.should_skip_update then
self.should_skip_update = false
return
end

self.tx:update_activity(activity)
else
if self.config.hooks.on_idle then self.config.hooks.on_idle(self.opts) end

if self.should_skip_update then
self.should_skip_update = false
return
end

self.tx:clear_activity()
end
end
Expand All @@ -221,6 +224,11 @@ function ActivityManager:update_activity()
self.config.hooks.on_activity(self.opts, activity)
end

if self.should_skip_update then
self.should_skip_update = false
return
end

self.tx:update_activity(activity)
end

Expand Down

0 comments on commit 93636dd

Please sign in to comment.