@@ -57,31 +57,6 @@ local TradeQueryClass = newClass("TradeQuery", function(self, itemsTab)
5757 self .lastQueries = {}
5858
5959 self .tradeQueryRequests = new (" TradeQueryRequests" )
60- local function onRateLimit (backoff )
61- self .backoffFinish = get_time () + backoff
62- self .countDown = coroutine.create (function ()
63- while self .backoffFinish do
64- local now = get_time ()
65- if self .backoffFinish < (now + 0.5 ) then
66- self .backoffFinish = nil
67- self :SetNotice (self .controls .pbNotice , " " )
68- return
69- end
70- local msg = s_format (" Rate limited. Retrying after %s seconds..." , self .backoffFinish - now )
71- self :SetNotice (self .controls .pbNotice , colorCodes .WARNING .. msg )
72- coroutine.yield ()
73- end
74- end )
75- end
76- main .onFrameFuncs [" TradeQueryRequests" ] = function ()
77- self .tradeQueryRequests :ProcessQueue (onRateLimit )
78- if self .countDown then
79- coroutine.resume (self .countDown )
80- if coroutine.status (self .countDown ) == " dead" then
81- self .countDown = nil
82- end
83- end
84- end
8560 if not main .api then
8661 main .api = new (" PoEAPI" , main .lastToken , main .lastRefreshToken , main .tokenExpiry )
8762 end
@@ -643,6 +618,32 @@ Highest Weight - Displays the order retrieved from trade]]
643618 self .controls .scrollBar :SetContentDimension (self .pane_height - 100 , self .effective_rows_height )
644619 self .controls .sectionAnchor .y = - self .controls .scrollBar .offset
645620 end
621+
622+ local function onRateLimit (backoff )
623+ self .backoffFinish = get_time () + backoff
624+ self .countDown = coroutine.create (function ()
625+ while self .backoffFinish do
626+ local now = get_time ()
627+ if self .backoffFinish < (now + 0.5 ) then
628+ self .backoffFinish = nil
629+ self :SetNotice (self .controls .pbNotice , " " )
630+ return
631+ end
632+ local msg = s_format (" Rate limited. Retrying after %s seconds..." , self .backoffFinish - now )
633+ self :SetNotice (self .controls .pbNotice , colorCodes .WARNING .. msg )
634+ coroutine.yield ()
635+ end
636+ end )
637+ end
638+ main .onFrameFuncs [" TradeQueryRequests" ] = function ()
639+ self .tradeQueryRequests :ProcessQueue (onRateLimit )
640+ if self .countDown then
641+ coroutine.resume (self .countDown )
642+ if coroutine.status (self .countDown ) == " dead" then
643+ self .countDown = nil
644+ end
645+ end
646+ end
646647 main :OpenPopup (pane_width , self .pane_height , " Trader" , self .controls , nil , nil , " close" , (scrollBarShown and scrollBarFunc or nil ))
647648end
648649
0 commit comments