@davoodmehraban89 / Factor-easy-2 Mirror · read-only / commits / 634f46b
Fork 0

سامانه صدور فاکتور و حسابداری

Mirrored from https://github.com/davoodmehraban89/Factor-easy.git

Synced Dec 4, 08:00 UTC

fix(B03-R3): isolate recovery rendering in js/sync.js

davoodmehraban89 committed Nov 24, 2026 at 17:06 UTC 634f46ba40b6da96937160f7de8609386e7e27f1
1 file changed +14
js/sync.js
+14
@@ -7,8 +7,22 @@ function getMyPurchases(){return !currentUser?[]:(datastore.purchases||[]).filte
7 function getMyCheques(){return !currentUser?[]:datastore.cheques.filter(c=>c.ownerUserId===currentUser.id);}
8 function getMyExpenses(){return !currentUser?[]:datastore.expenses.filter(e=>e.ownerUserId===currentUser.id);}
9 function getMyPayments(){return !currentUser?[]:(datastore.payments||[]).filter(p=>p.ownerUserId===currentUser.id);}
10 +// Synchronous render-only scope. Never hold across an await or suppress saves globally.
11 +let finoraReadOnlyRefreshDepth=0;
12 +function finoraIsReadOnlyRefresh(){return finoraReadOnlyRefreshDepth>0;}
13 +function finoraWithReadOnlyRefresh(render){
14 + finoraReadOnlyRefreshDepth++;
15 + try{return render();}finally{finoraReadOnlyRefreshDepth--;}
16 +}
17 function getMySettings(){
18 if(!currentUser)return{invoice_kind:'non_formal',vat_mode:'none',vat_rate:10,default_company_id:'',currency_mode:'rial',currency_custom:''};
19 + if(finoraIsReadOnlyRefresh()){
20 + const existing=(Array.isArray(datastore.settings)?datastore.settings:[]).find(item=>item.ownerUserId===currentUser.id);
21 + const view=existing?JSON.parse(JSON.stringify(existing)):{ownerUserId:currentUser.id,invoice_kind:'non_formal',vat_mode:'none',vat_rate:10,default_company_id:''};
22 + if(typeof view.currency_mode==='undefined')view.currency_mode='rial';
23 + if(typeof view.currency_custom==='undefined')view.currency_custom='';
24 + return view;
25 + }
26 if(!Array.isArray(datastore.settings))datastore.settings=[];
27 let s=datastore.settings.find(item=>item.ownerUserId===currentUser.id);
28 if(!s){s={ownerUserId:currentUser.id,invoice_kind:'non_formal',vat_mode:'none',vat_rate:10,default_company_id:'',currency_mode:'rial',currency_custom:''};datastore.settings.push(s);}