Merge pull request #250 from Reiling-Jeff/main
fix(arch-updater): reduce CPU work in the HTTP callback
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
id = "yuuto/arch-updater"
|
id = "yuuto/arch-updater"
|
||||||
name = "Arch Updater"
|
name = "Arch Updater"
|
||||||
version = "1.0.0"
|
version = "1.0.1"
|
||||||
plugin_api = 9
|
plugin_api = 9
|
||||||
author = "yuuto"
|
author = "yuuto"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ local sinceCheck = 0
|
|||||||
local startupTicks = 0
|
local startupTicks = 0
|
||||||
local sinceNewsCheck = 0
|
local sinceNewsCheck = 0
|
||||||
local newsStateLoaded = false
|
local newsStateLoaded = false
|
||||||
|
local newsDirty = false
|
||||||
|
|
||||||
local startCheck
|
local startCheck
|
||||||
local checkNews
|
local checkNews
|
||||||
@@ -537,7 +538,7 @@ checkNews = function()
|
|||||||
local parsed, items = pcall(parseNewsFeed, res.body)
|
local parsed, items = pcall(parseNewsFeed, res.body)
|
||||||
if parsed and type(items) == "table" then
|
if parsed and type(items) == "table" then
|
||||||
applyNewsItems(items)
|
applyNewsItems(items)
|
||||||
publish()
|
newsDirty = true
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
if not ok then
|
if not ok then
|
||||||
@@ -737,6 +738,11 @@ function update()
|
|||||||
checkNews()
|
checkNews()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if newsDirty then
|
||||||
|
newsDirty = false
|
||||||
|
publish()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
noctalia.setUpdateInterval(1000)
|
noctalia.setUpdateInterval(1000)
|
||||||
|
|||||||
Reference in New Issue
Block a user