bugfixing watchlist
This commit is contained in:
parent
ae69e75b96
commit
73ee265f77
@ -666,12 +666,17 @@
|
|||||||
displayList = [...displayList, ...filteredItem];
|
displayList = [...displayList, ...filteredItem];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
$: if ($isOpen) {
|
// Helper function to safely parse JSON
|
||||||
websocketRealtimeData();
|
function safeParse(value) {
|
||||||
console.log("WebSocket restarted");
|
try {
|
||||||
|
return JSON.parse(value);
|
||||||
|
} catch (error) {
|
||||||
|
// If JSON parsing fails, just return the original value
|
||||||
|
return value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
try {
|
try {
|
||||||
const savedRules = localStorage?.getItem("watchlist-ruleOfList");
|
const savedRules = localStorage?.getItem("watchlist-ruleOfList");
|
||||||
@ -713,24 +718,16 @@
|
|||||||
checkedItems = new Set(ruleOfList?.map((item) => item.name));
|
checkedItems = new Set(ruleOfList?.map((item) => item.name));
|
||||||
allRows = sortIndicatorCheckMarks(allRows);
|
allRows = sortIndicatorCheckMarks(allRows);
|
||||||
|
|
||||||
// Parse savedLastWatchlistId safely
|
// Safely parse savedLastWatchlistId using safeParse
|
||||||
|
let parsedLastWatchlistId = null;
|
||||||
if (savedLastWatchlistId && savedLastWatchlistId.length > 0) {
|
if (savedLastWatchlistId && savedLastWatchlistId.length > 0) {
|
||||||
let parsedLastWatchlistId;
|
parsedLastWatchlistId = safeParse(savedLastWatchlistId);
|
||||||
try {
|
|
||||||
parsedLastWatchlistId = JSON.parse(savedLastWatchlistId);
|
|
||||||
} catch (error) {
|
|
||||||
console.error(
|
|
||||||
"Error parsing last watchlist id from localStorage. Using raw value instead.",
|
|
||||||
error,
|
|
||||||
);
|
|
||||||
parsedLastWatchlistId = savedLastWatchlistId;
|
|
||||||
}
|
|
||||||
|
|
||||||
displayWatchList = allList?.find(
|
|
||||||
(item) => item?.id === parsedLastWatchlistId,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
displayWatchList = allList?.find(
|
||||||
|
(item) => item?.id === parsedLastWatchlistId,
|
||||||
|
);
|
||||||
|
|
||||||
// If no valid watchlist is found, default to the first element of allList
|
// If no valid watchlist is found, default to the first element of allList
|
||||||
if (!displayWatchList && allList?.length > 0) {
|
if (!displayWatchList && allList?.length > 0) {
|
||||||
displayWatchList = allList.at(0);
|
displayWatchList = allList.at(0);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user