Skip to content

Commit 849ef36

Browse files
committed
Cancel power report calcs through toast message
1 parent 703f469 commit 849ef36

2 files changed

Lines changed: 16 additions & 5 deletions

File tree

src/Classes/TreeTab.lua

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ local TreeTabClass = newClass("TreeTab", "ControlHost", function(self, build)
207207
self.controls.treeHeatMapStatSelect.shown = state
208208

209209
if state == false then
210-
self.controls.powerReportList.shown = false
210+
self.controls.powerReportList.shown = false
211211
end
212212
end)
213213

@@ -302,12 +302,17 @@ local TreeTabClass = newClass("TreeTab", "ControlHost", function(self, build)
302302

303303
self.controls.powerReportList.label = message
304304
self.lastProgressToastUpdate = now
305-
local toastIndex = findToastIndex("^Building Power Report")
305+
local toastIndex = findToastIndex("^Cancelling")
306306
if toastIndex then
307-
main.toastMessages[toastIndex] = message
307+
self.viewer.showHeatMap = false
308308
else
309-
t_insert(main.toastMessages, message)
310-
self.powerBuilderToastActive = true
309+
toastIndex = findToastIndex("^Building Power Report")
310+
if toastIndex then
311+
main.toastMessages[toastIndex] = message
312+
else
313+
t_insert(main.toastMessages, message)
314+
self.powerBuilderToastActive = true
315+
end
311316
end
312317
end
313318
-- Completion callback from the CalcsTab power builder coroutine

src/Modules/Main.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,9 @@ function main:Init()
236236
self.controls.dismissToast = new("ButtonControl", {"BOTTOMLEFT",self.anchorMain,"BOTTOMLEFT"}, {0, function() return -self.mainBarHeight + self.toastHeight end, 80, 20}, "Dismiss", function()
237237
self.toastMode = "HIDING"
238238
self.toastStart = GetTime()
239+
if self.toastMessages[1]:match("^Building Power Report") then
240+
self.toastMessages[1] = "Cancelling"
241+
end
239242
end)
240243
self.controls.dismissToast.shown = function()
241244
return self.toastMode == "SHOWN"
@@ -386,6 +389,9 @@ function main:OnFrame()
386389

387390
-- Run toasts
388391
if self.toastMessages[1] then
392+
if self.toastMessages[1]:match("^Building Power Report") then
393+
self.controls.dismissToast.label = "Cancel"
394+
end
389395
if not self.toastMode then
390396
self.toastMode = "SHOWING"
391397
self.toastStart = GetTime()

0 commit comments

Comments
 (0)