Simplify Studio 2 sources and persist private previews and LoRA lists
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
export async function cachedLoras({read,write,live,fresh=false}) {
|
||||
const cached=read() || {image:[],video:[]};
|
||||
if (!fresh && (cached.image?.length || cached.video?.length)) return cached;
|
||||
try {
|
||||
const listed=await live();
|
||||
const next={image:listed.image?.length?listed.image:cached.image||[],video:listed.video?.length?listed.video:cached.video||[]};
|
||||
if(next.image.length || next.video.length) write(next);
|
||||
return next;
|
||||
} catch { return cached; }
|
||||
}
|
||||
Reference in New Issue
Block a user