Skip to content

Commit

Permalink
Add warning when undoing a Rojo patch
Browse files Browse the repository at this point in the history
  • Loading branch information
boatbomber committed Jul 4, 2023
1 parent ef7a66e commit 315b127
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions plugin/src/App/init.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
local ChangeHistoryService = game:GetService("ChangeHistoryService")
local Players = game:GetService("Players")
local ServerStorage = game:GetService("ServerStorage")

Expand Down Expand Up @@ -54,6 +55,14 @@ function App:init()
self.confirmationBindable = Instance.new("BindableEvent")
self.confirmationEvent = self.confirmationBindable.Event

self.waypointConnection = ChangeHistoryService.OnUndo:Connect(function(action: string)
if string.find(action, "^Rojo: Patch") then
local message = string.format("You've undone '%s'.\nIf this was not intended, please Redo in the topbar or with Ctrl/⌘+Y.", action)
Log.warn(message)
self:addNotification(message, 10)
end
end)

self:setState({
appStatus = AppStatus.NotConnected,
guiEnabled = false,
Expand All @@ -67,6 +76,11 @@ function App:init()
})
end

function App:didUnmount()
self.waypointConnection:Disconnect()
self.confirmationBindable:Destroy()
end

function App:addNotification(text: string, timeout: number?)
if not Settings:get("showNotifications") then
return
Expand Down

0 comments on commit 315b127

Please sign in to comment.