mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-20 17:41:37 +00:00
Fix notification unmount thread cancel bug (#1211)
This commit is contained in:
parent
2a1102fc55
commit
68eab3479a
3 changed files with 17 additions and 2 deletions
|
|
@ -19,9 +19,15 @@ local FullscreenNotification = Roact.Component:extend("FullscreeFullscreenNotifi
|
|||
function FullscreenNotification:init()
|
||||
self.transparency, self.setTransparency = Roact.createBinding(0)
|
||||
self.lifetime = self.props.timeout
|
||||
self.dismissed = false
|
||||
end
|
||||
|
||||
function FullscreenNotification:dismiss()
|
||||
if self.dismissed then
|
||||
return
|
||||
end
|
||||
self.dismissed = true
|
||||
|
||||
if self.props.onClose then
|
||||
self.props.onClose()
|
||||
end
|
||||
|
|
@ -59,7 +65,7 @@ function FullscreenNotification:didMount()
|
|||
end
|
||||
|
||||
function FullscreenNotification:willUnmount()
|
||||
if self.timeout and coroutine.status(self.timeout) ~= "dead" then
|
||||
if self.timeout and coroutine.status(self.timeout) == "suspended" then
|
||||
task.cancel(self.timeout)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ function Notification:init()
|
|||
self.binding = bindingUtil.fromMotor(self.motor)
|
||||
|
||||
self.lifetime = self.props.timeout
|
||||
self.dismissed = false
|
||||
|
||||
self.motor:onStep(function(value)
|
||||
if value <= 0 and self.props.onClose then
|
||||
|
|
@ -34,6 +35,11 @@ function Notification:init()
|
|||
end
|
||||
|
||||
function Notification:dismiss()
|
||||
if self.dismissed then
|
||||
return
|
||||
end
|
||||
self.dismissed = true
|
||||
|
||||
self.motor:setGoal(Flipper.Spring.new(0, {
|
||||
frequency = 5,
|
||||
dampingRatio = 1,
|
||||
|
|
@ -75,7 +81,7 @@ function Notification:didMount()
|
|||
end
|
||||
|
||||
function Notification:willUnmount()
|
||||
if self.timeout and coroutine.status(self.timeout) ~= "dead" then
|
||||
if self.timeout and coroutine.status(self.timeout) == "suspended" then
|
||||
task.cancel(self.timeout)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue