mirror of
https://github.com/kbenestad/reimburse.git
synced 2026-06-18 08:04:31 +00:00
Fix crash: state initialized before CFG is loaded
state.baseCurrency was set to CFG['currency-base'] at declaration time, but CFG is only populated after await loadConfig(). Reading a property of undefined throws synchronously, crashing the script before init() runs. Move the assignment to after loadConfig() resolves in init(). https://claude.ai/code/session_014uUwDBtG5y5FuWcy5zqVD1
This commit is contained in:
parent
e1292822f8
commit
156c76baae
1 changed files with 2 additions and 1 deletions
|
|
@ -140,7 +140,7 @@ async function loadConfig() {
|
|||
}
|
||||
|
||||
// ========== STATE ==========
|
||||
const state = { staff: '', periodFrom: '', periodTo: '', baseCurrency: CFG['currency-base'], fxRateMemory: {}, items: [], _grandTotal: 0 };
|
||||
const state = { staff: '', periodFrom: '', periodTo: '', baseCurrency: '', fxRateMemory: {}, items: [], _grandTotal: 0 };
|
||||
|
||||
function newItem() { return { id: uid(), name: '', lines: [newLine()], _subtotal: 0 }; }
|
||||
function newLine() {
|
||||
|
|
@ -848,6 +848,7 @@ async function onGenerate() {
|
|||
async function init() {
|
||||
try {
|
||||
await loadConfig();
|
||||
state.baseCurrency = CFG['currency-base'];
|
||||
state.items.push(newItem());
|
||||
render();
|
||||
} catch (e) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue