Skip to content
This repository has been archived by the owner on Sep 26, 2024. It is now read-only.

[NC]: Get updated storage recordings fix #54

Merged
merged 7 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions apps/mocksi-lite/content/Popup/CreateDemo/DemoItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ const DemoItem = ({

return (
<div className={"flex justify-between w-full px-6"}>
<div>
<TextField variant={"title"}>{demo_name}</TextField>
<TextField>{customer_name}</TextField>
<div className={"w-[200px]"}>
<TextField variant={"title"} className={"truncate"}>
{demo_name}
</TextField>
<TextField className={"truncate"}>{customer_name}</TextField>
</div>
<div className={"flex gap-3"}>
<Button
Expand Down
29 changes: 22 additions & 7 deletions apps/mocksi-lite/content/Popup/CreateDemo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,30 @@ const CreateDemo = ({
setState,
}: CreateDemoProps) => {
const [recordings, setRecordings] = useState<Recording[]>([]);

const getRecordings = async () => {
let continueFetching = true;
while (continueFetching) {
try {
const results = await chrome.storage.local.get(["recordings"]);
const newRecordings = JSON.parse(results.recordings ?? "{}");
if (newRecordings.length !== recordings.length) {
setRecordings(newRecordings);
continueFetching = false; // Stop the loop if recordings have been updated
}
} catch (error) {
continueFetching = false; // Stop the loop in case of an error
console.error("Failed to fetch recordings:", error);
}
}
};

// biome-ignore lint/correctness/useExhaustiveDependencies:
useEffect(() => {
try {
chrome.storage.local.get(["recordings"], (results) =>
setRecordings(JSON.parse(results.recordings) ?? []),
);
} catch (error) {
console.error("Error retrieving recordings from storage:", error);
if (!createForm) {
getRecordings();
}
}, []);
}, [createForm]);

const handleCancelClick = (recordings?: Recording[]) => {
if (recordings) {
Expand Down
Loading