single-item: prevent circular refs
Signed-off-by: Varun Patil <radialapps@gmail.com>pull/653/head
parent
bff4f44003
commit
c5833c97ad
|
@ -13,16 +13,18 @@ export function isSingleItem(): boolean {
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getSingleItemData(): Promise<IDay[]> {
|
export async function getSingleItemData(): Promise<IDay[]> {
|
||||||
if (!singleItem?.fileid) {
|
if (!singleItem?.fileid) return [];
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Make days array
|
||||||
singleItem.key = singleItem.fileid;
|
singleItem.key = singleItem.fileid;
|
||||||
return [
|
const days = [
|
||||||
{
|
{
|
||||||
dayid: singleItem.dayid,
|
dayid: singleItem.dayid,
|
||||||
count: 1,
|
count: 1,
|
||||||
detail: [singleItem],
|
detail: [singleItem],
|
||||||
},
|
},
|
||||||
] as any[];
|
];
|
||||||
|
|
||||||
|
// Return copy to prevent circular reference
|
||||||
|
return JSON.parse(JSON.stringify(days));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue