Skip to content

Commit

Permalink
Revert "fix: update svelte 5 and fix reactive infinity loop problem"
Browse files Browse the repository at this point in the history
This reverts commit 826a089.
  • Loading branch information
Ahmedhossamdev committed Nov 27, 2024
1 parent 4b9dd66 commit 054b7ea
Showing 1 changed file with 17 additions and 23 deletions.
40 changes: 17 additions & 23 deletions src/components/stops/StopPane.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<script>
import { run } from 'svelte/legacy';
import ArrivalDeparture from '$components/ArrivalDeparture.svelte';
import TripDetailsPane from '$components/oba/TripDetailsPane.svelte';
import LoadingSpinner from '$components/LoadingSpinner.svelte';
Expand All @@ -12,20 +10,15 @@
import '$lib/i18n.js';
import { isLoading, t } from 'svelte-i18n';
/**
* @typedef {Object} Props
* @property {any} stop
* @property {any} [arrivalsAndDeparturesResponse]
*/
/** @type {Props} */
let { stop, arrivalsAndDeparturesResponse = $bindable(null) } = $props();
export let stop;
export let arrivalsAndDeparturesResponse = null;
let arrivalsAndDepartures = $state();
let loading = $state(false);
let error = $state();
let arrivalsAndDepartures;
let loading = false;
let error;
let interval = null;
let initialDataLoaded = false;
const dispatch = createEventDispatcher();
Expand All @@ -52,11 +45,14 @@
}, 30000);
}
$effect(() => {
if (stop?.id) {
clearInterval(interval);
resetDataFetchInterval(stop.id);
}
$: if (stop?.id && initialDataLoaded) {
clearInterval(interval);
resetDataFetchInterval(stop.id);
}
onMount(() => {
loadData(stop.id);
initialDataLoaded = true;
});
onDestroy(() => {
Expand Down Expand Up @@ -122,11 +118,9 @@
<Accordion on:activeChanged={handleAccordionSelectionChanged}>
{#each arrivalsAndDepartures.arrivalsAndDepartures as arrival}
<AccordionItem data={arrival}>
{#snippet header()}
<span>
<ArrivalDeparture arrivalDeparture={arrival} />
</span>
{/snippet}
<span slot="header">
<ArrivalDeparture arrivalDeparture={arrival} />
</span>
<TripDetailsPane {stop} tripId={arrival.tripId} serviceDate={arrival.serviceDate} />
</AccordionItem>
{/each}
Expand Down

0 comments on commit 054b7ea

Please sign in to comment.