perf(report): load side wrinkle layers after report entry
This commit is contained in:
+12
-1
@@ -185,5 +185,16 @@ module.exports = function createAccounts(root, env = process.env) {
|
||||
try { return JSON.parse(fs.readFileSync(path.join(snapshots, user.id, id + '.json'), 'utf8')).presentation || null; }
|
||||
catch (_) { return null; }
|
||||
}
|
||||
return { route, session, storeReport, reportPresentation, sameOrigin, wechatAvailable: available };
|
||||
function reportSnapshot(ownerId,id) {
|
||||
if (!db.users.some(u=>u.id===ownerId&&u.kind==='wechat') || !/^R[\w-]+$/.test(id)) return null;
|
||||
try {return JSON.parse(fs.readFileSync(path.join(snapshots,ownerId,id+'.json'),'utf8'));} catch (_) {return null;}
|
||||
}
|
||||
function updateWrinkleViews(ownerId,id,views) {
|
||||
const snapshot=reportSnapshot(ownerId,id);
|
||||
if (!snapshot) return;
|
||||
snapshot.payload.wrinkle_views=views;
|
||||
if (snapshot.payload.wrinkle_job) snapshot.payload.wrinkle_job.status='complete';
|
||||
atomic(path.join(snapshots,ownerId,id+'.json'),snapshot);
|
||||
}
|
||||
return { route, session, storeReport, reportPresentation, reportSnapshot, updateWrinkleViews, sameOrigin, wechatAvailable: available };
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user