From ff73d8490ba88959f337159463d48dab0fe7efa6 Mon Sep 17 00:00:00 2001 From: Gabriel Tofvesson Date: Fri, 4 Oct 2024 16:06:23 +0200 Subject: [PATCH] Actaully render page --- itemcontroller.lua | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/itemcontroller.lua b/itemcontroller.lua index d9219b4..124bcc1 100644 --- a/itemcontroller.lua +++ b/itemcontroller.lua @@ -122,6 +122,15 @@ local function itemList(groups, wBudget, onClick) } end +local function updatePageRender(state, pages) + if state.nextPage ~= nil then + state.currentPage = state.nextPage + state.nextPage = nil + + state._pageRender = pages[state.currentPage](state) + end +end + local function renderDefault(state, rootElement) local event = {os.pullEvent()} local handled = rootElement:handleEvent(event) @@ -193,12 +202,6 @@ local CONTROLLER_STATE = { os.queueEvent("dummy_event") while not CONTROLLER_STATE.exit do - PAGES[CONTROLLER_STATE.currentPage](CONTROLLER_STATE) - - if CONTROLLER_STATE.nextPage ~= nil then - CONTROLLER_STATE.currentPage = CONTROLLER_STATE.nextPage - CONTROLLER_STATE.nextPage = nil - end - - sleep(0) + updatePageRender(CONTROLLER_STATE, PAGES) + CONTROLLER_STATE._pageRender() end \ No newline at end of file