mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-21 05:06:29 +00:00
Check for compatible updates in plugin (#832)
This commit is contained in:
@@ -4,6 +4,7 @@ local Packages = Rojo.Packages
|
||||
|
||||
local Roact = require(Packages.Roact)
|
||||
|
||||
local timeUtil = require(Plugin.timeUtil)
|
||||
local Theme = require(Plugin.App.Theme)
|
||||
local Assets = require(Plugin.Assets)
|
||||
local PatchSet = require(Plugin.PatchSet)
|
||||
@@ -20,28 +21,6 @@ local TableDiffVisualizer = require(Plugin.App.Components.TableDiffVisualizer)
|
||||
|
||||
local e = Roact.createElement
|
||||
|
||||
local AGE_UNITS = {
|
||||
{ 31556909, "y" },
|
||||
{ 2629743, "mon" },
|
||||
{ 604800, "w" },
|
||||
{ 86400, "d" },
|
||||
{ 3600, "h" },
|
||||
{ 60, "m" },
|
||||
}
|
||||
function timeSinceText(elapsed: number): string
|
||||
local ageText = string.format("%ds", elapsed)
|
||||
|
||||
for _, UnitData in ipairs(AGE_UNITS) do
|
||||
local UnitSeconds, UnitName = UnitData[1], UnitData[2]
|
||||
if elapsed > UnitSeconds then
|
||||
ageText = elapsed // UnitSeconds .. UnitName
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
return ageText
|
||||
end
|
||||
|
||||
local ChangesViewer = Roact.Component:extend("ChangesViewer")
|
||||
|
||||
function ChangesViewer:init()
|
||||
@@ -287,7 +266,7 @@ function ConnectedPage:getChangeInfoText()
|
||||
if patchData == nil then
|
||||
return ""
|
||||
end
|
||||
return timeSinceText(DateTime.now().UnixTimestamp - patchData.timestamp)
|
||||
return timeUtil.elapsedToText(DateTime.now().UnixTimestamp - patchData.timestamp)
|
||||
end
|
||||
|
||||
function ConnectedPage:startChangeInfoTextUpdater()
|
||||
@@ -303,7 +282,7 @@ function ConnectedPage:startChangeInfoTextUpdater()
|
||||
local updateInterval = 1
|
||||
|
||||
-- Update timestamp text as frequently as currently needed
|
||||
for _, UnitData in ipairs(AGE_UNITS) do
|
||||
for _, UnitData in ipairs(timeUtil.AGE_UNITS) do
|
||||
local UnitSeconds = UnitData[1]
|
||||
if elapsed > UnitSeconds then
|
||||
updateInterval = UnitSeconds
|
||||
|
||||
@@ -162,6 +162,25 @@ function SettingsPage:render()
|
||||
layoutOrder = layoutIncrement(),
|
||||
}),
|
||||
|
||||
CheckForUpdates = e(Setting, {
|
||||
id = "checkForUpdates",
|
||||
name = "Check For Updates",
|
||||
description = "Notify about newer compatible Rojo releases",
|
||||
transparency = self.props.transparency,
|
||||
layoutOrder = layoutIncrement(),
|
||||
}),
|
||||
|
||||
CheckForPreleases = e(Setting, {
|
||||
id = "checkForPrereleases",
|
||||
name = "Include Prerelease Updates",
|
||||
description = "Include prereleases when checking for updates",
|
||||
transparency = self.props.transparency,
|
||||
layoutOrder = layoutIncrement(),
|
||||
visible = if string.find(debug.traceback(), "\n[^\n]-user_.-$") == nil
|
||||
then false -- Must be a local install to allow prerelease checks
|
||||
else Settings:getBinding("checkForUpdates"),
|
||||
}),
|
||||
|
||||
AutoConnectPlaytestServer = e(Setting, {
|
||||
id = "autoConnectPlaytestServer",
|
||||
name = "Auto Connect Playtest Server",
|
||||
|
||||
Reference in New Issue
Block a user