refactor code

This commit is contained in:
MuslemRahimi 2024-11-11 11:35:36 +01:00
parent e13c9e6d42
commit 3ccd3af1aa
3 changed files with 5 additions and 36 deletions

View File

@ -120,7 +120,6 @@ export const oauthState = writable(<string>"");
export const oauthVerifier = writable(<string>""); export const oauthVerifier = writable(<string>"");
export const oauthProvider = writable(<string>""); export const oauthProvider = writable(<string>"");
export const switchWatchList = writable(<boolean>false);
export const cachedPosts = writable(<Array<any>>{}); export const cachedPosts = writable(<Array<any>>{});
export const currentPagePosition = writable(<Number>0); export const currentPagePosition = writable(<Number>0);

View File

@ -1,31 +1,5 @@
export const load = async ({ locals }) => { export const load = async ({ locals }) => {
/*
const getMiniPlotsIndex = async () => {
let output;
// Get cached data for the specific tickerID
const cachedData = getCache('', 'getMiniPlotsIndex');
if (cachedData) {
output = cachedData;
} else {
const {apiKey, apiURL} = await parent();
// make the POST request to the endpoint
const response = await fetch(apiURL + '/mini-plots-index', {
method: 'GET',
headers: {
"Content-Type": "application/json", "X-API-KEY": apiKey
},
});
output = await response.json();
setCache('', output, 'getMiniPlotsIndex');
}
return output;
};
*/
const getAllWatchlist = async () => { const getAllWatchlist = async () => {
const { pb, user } = locals; const { pb, user } = locals;

View File

@ -3,7 +3,6 @@
searchBarData, searchBarData,
screenWidth, screenWidth,
numberOfUnreadNotification, numberOfUnreadNotification,
switchWatchList,
} from "$lib/store"; } from "$lib/store";
import { formatDate, abbreviateNumber } from "$lib/utils"; import { formatDate, abbreviateNumber } from "$lib/utils";
import toast from "svelte-french-toast"; import toast from "svelte-french-toast";
@ -17,6 +16,7 @@
export let data; export let data;
let searchQuery = ""; let searchQuery = "";
let switchWatchlist = false;
let editMode = false; let editMode = false;
let numberOfChecked = 0; let numberOfChecked = 0;
let deleteTickerList = []; let deleteTickerList = [];
@ -425,7 +425,7 @@
function changeWatchList(newWatchList) { function changeWatchList(newWatchList) {
displayWatchList = newWatchList; displayWatchList = newWatchList;
$switchWatchList = true; switchWatchlist = true;
} }
function saveRules() { function saveRules() {
@ -502,10 +502,6 @@
} }
}); });
onDestroy(() => {
$switchWatchList = false;
});
function handleWatchlistModal() { function handleWatchlistModal() {
const closePopup = document.getElementById("addWatchlist"); const closePopup = document.getElementById("addWatchlist");
closePopup?.dispatchEvent(new MouseEvent("click")); closePopup?.dispatchEvent(new MouseEvent("click"));
@ -579,11 +575,11 @@
$: charNumber = $screenWidth < 640 ? 15 : 20; $: charNumber = $screenWidth < 640 ? 15 : 20;
$: { $: {
if ($switchWatchList && typeof window !== "undefined") { if (switchWatchlist && typeof window !== "undefined") {
isLoaded = false; isLoaded = false;
getWatchlistData(); getWatchlistData();
isLoaded = true; isLoaded = true;
$switchWatchList = false; switchWatchlist = false;
} }
} }