Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions src/contentproviderutils/src/Client/ImageLabelLoaded.lua
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ end
function ImageLabelLoaded.PromiseLoaded(self: ImageLabelLoaded, timeout: number?): Promise.Promise<()>
assert(type(timeout) == "number" or timeout == nil, "Bad timeout")

local originalTimeout = timeout
timeout = timeout or self._defaultTimeout

if self._isLoaded.Value then
Expand All @@ -81,19 +80,17 @@ function ImageLabelLoaded.PromiseLoaded(self: ImageLabelLoaded, timeout: number?
end
end))

maid:GiveTask(self.ImageChanged:Connect(function(isVisible)
if not isVisible then
promise:Reject()
end
maid:GiveTask(self.ImageChanged:Connect(function()
promise:Reject("[ImageLabelLoaded] - The image label changed before the image loaded")
end))

if timeout then
maid:GiveTask(task.delay(timeout, function()
if originalTimeout then
promise:Reject("[ImageLabelLoaded] - Failed to load image after default timeout time")
else
promise:Reject()
end
local timeoutSeconds: number = timeout

maid:GiveTask(task.delay(timeoutSeconds, function()
promise:Reject(
string.format("[ImageLabelLoaded] - Failed to load image after %0.2f seconds", timeoutSeconds)
)
end))
end

Expand Down
Loading