diff --git a/src/components/ChannelItem.svelte b/src/components/ChannelItem.svelte index 7a282e40e..3c6c888b1 100644 --- a/src/components/ChannelItem.svelte +++ b/src/components/ChannelItem.svelte @@ -8,6 +8,7 @@ import ClosedBadge from './ClosedBadge.svelte' import { downloadMode, selected } from '~/store' import { fade } from 'svelte/transition' + import { pushState } from '$app/navigation' export let channel @@ -21,10 +22,10 @@ let prevUrl = '/' const onOpened = () => { prevUrl = window.location.href - window.history.pushState({}, `${displayName} • iptv-org`, `/channels/${country}/${name}`) + pushState(`/channels/${country}/${name}`, {}) } const onClose = () => { - window.history.pushState({}, `iptv-org`, prevUrl) + pushState(prevUrl, {}) } const showGuides = () => open( diff --git a/src/store.js b/src/store.js index ed371bea0..aca823d4c 100644 --- a/src/store.js +++ b/src/store.js @@ -4,6 +4,7 @@ import sj from '@freearhey/search-js' import _ from 'lodash' import { browser } from '$app/environment' import { Channel } from './models' +import { pushState } from '$app/navigation' export const query = writable('') export const hasQuery = writable(false) @@ -68,15 +69,13 @@ export async function fetchChannels() { } export function setSearchParam(key, value) { - if (window.history.pushState) { - let query = key && value ? `?${key}=${value}` : '' - query = query.replace(/\+/g, '%2B') - const url = `${window.location.protocol}//${window.location.host}${window.location.pathname}${query}` - const state = {} - state[key] = value - window.history.pushState(state, '', url) - setPageTitle(value) - } + let query = key && value ? `?${key}=${value}` : '' + query = query.replace(/\+/g, '%2B') + const url = `${window.location.protocol}//${window.location.host}${window.location.pathname}${query}` + const state = {} + state[key] = value + pushState(url, state) + setPageTitle(value) } export function setPageTitle(value) {