Code optimizations

This commit is contained in:
2022-06-07 14:54:28 +02:00
parent 218676b9ca
commit 85aacf12e3
4 changed files with 16 additions and 15 deletions

View File

@@ -9,12 +9,13 @@
import Button from '$components/atoms/Button.svelte'
import Location from '$components/molecules/Location.svelte'
export let locations: any
export let locations: any[]
const { continents, settings: { explore_list }} = getContext('global')
// Continents filtering logic
let currentContinent: string = undefined
$: filteredLocations = locations.filter(({ country: { continent }}: any) => {
if (!currentContinent) {
// Show all locations by default
@@ -30,11 +31,7 @@
* Filter locations from continent
*/
const filterLocation = throttle((continent: string) => {
if (continent !== currentContinent) {
currentContinent = continent
} else {
currentContinent = undefined
}
currentContinent = continent !== currentContinent ? continent : null
}, 700)
</script>