Skip to content

Commit

Permalink
Remove too tiny and page-specific helper from global router
Browse files Browse the repository at this point in the history
  • Loading branch information
ai committed Oct 8, 2024
1 parent c679302 commit ed9c7d2
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 26 deletions.
10 changes: 0 additions & 10 deletions core/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,16 +200,6 @@ export function isOtherRoute(route: Route): boolean {
return SETTINGS.has(route.route) || ORGANIZE.has(route.route)
}

export function removeFeedFromRoute(): void {
let page = router.get()
if (page.route === 'categories') {
getEnvironment().openRoute({
params: {},
route: page.route
})
}
}

export function backToFirstStep(): void {
let back = backRoute.get()
if (back) {
Expand Down
14 changes: 0 additions & 14 deletions core/test/router.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
deleteFeed,
isGuestRoute,
isOtherRoute,
removeFeedFromRoute,
router,
setBaseTestRoute,
testFeed,
Expand Down Expand Up @@ -256,16 +255,3 @@ test('backRoute handles export with format', () => {
route: 'export'
})
})

test('has helper on feed removing', async () => {
userId.set('10')
let feed = await addFeed(testFeed())
setBaseTestRoute({ params: { feed }, route: 'categories' })

removeFeedFromRoute()

deepStrictEqual(router.get(), {
params: {},
route: 'categories'
})
})
2 changes: 1 addition & 1 deletion web/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ http {

add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload";
add_header X-Content-Type-Options "nosniff";
add_header Content-Security-Policy "object-src 'none'; frame-ancestors 'none'; form-action 'none'; base-uri 'none'; style-src 'sha256-J1yr9jnezHa8fgkMcmmOquKcdW3HPJID3HI4njG+hY8=' 'sha256-eJHzD9wIr2E84rPeZQeXO3bt9ihyOFLyeZZXh4m3BpE=' 'self'; script-src 'sha256-u5afvzrVcDGTOxeBQWnrSgxFv/EOJ2lqLAWD6qzSSY8=' 'self'";
add_header Content-Security-Policy "object-src 'none'; frame-ancestors 'none'; form-action 'none'; base-uri 'none'; style-src 'sha256-0QQ5SKWRwEIVeUEt8MjrdaPQAH6rGm8EUwRB/xh07IQ=' 'sha256-eJHzD9wIr2E84rPeZQeXO3bt9ihyOFLyeZZXh4m3BpE=' 'self'; script-src 'sha256-iliif2S6Fr8mQazzDJs2huHUeow98/TYx+Staat/56E=' 'self'";

location ~* __ROUTES__ {
try_files /index.html =404;
Expand Down
13 changes: 12 additions & 1 deletion web/pages/feeds/edit.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@
moveFilterDown,
moveFilterUp,
type PostsList,
removeFeedFromRoute,
router,
sortFilters,
organizeMessages as t
} from '@slowreader/core'
import { openRoute } from '../../stores/router.ts'
import Button from '../../ui/button.svelte'
import Card from '../../ui/card.svelte'
import Loader from '../../ui/loader.svelte'
Expand Down Expand Up @@ -66,6 +67,16 @@
}
}
export function removeFeedFromRoute(): void {
let page = router.get()
if (page.route === 'categories') {
openRoute({
params: {},
route: page.route
})
}
}
let feed = $derived(getFeed(feedId))
let filters = $derived(getFilters({ feedId }))
let loadedPosts = $derived.by(() => {
Expand Down

0 comments on commit ed9c7d2

Please sign in to comment.