Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
falsandtru committed Feb 13, 2024
1 parent f103b85 commit 6130a0d
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 15 deletions.
2 changes: 1 addition & 1 deletion src/layer/domain/router/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export async function route(
? Right(undefined)
: Left(new Error(`Failed to match the areas`)))
.fmap(() =>
fetch(entity.event, entity.config, entity.state.process, io))
fetch(entity.event, entity.config, entity.state.process))
.fmap(async p => (await p)
.fmap(([res, seq]) =>
update(entity, res, seq, {
Expand Down
14 changes: 0 additions & 14 deletions src/layer/domain/router/module/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ import { xhr } from '../module/fetch/xhr';
import { Cancellee } from 'spica/cancellation';
import { Either } from 'spica/either';
import { wait as delay } from 'spica/timer';
import { html } from 'typed-dom/dom';

const style = html('style');

export async function fetch(
{
Expand All @@ -31,14 +28,7 @@ export async function fetch(
sequence,
}: Config,
process: Cancellee<Error>,
io: {
document: Document;
}
): Promise<Either<Error, readonly [Response, 'seq:fetch']>> {
const { scrollX, scrollY } = window;
if (type === RouterEventType.Popstate) {
io.document.documentElement.appendChild(style);
}
headers = new Headers(headers);
headers.has('Accept') || headers.set('Accept', 'text/html');
headers.has('X-Pjax') || headers.set('X-Pjax', JSON.stringify(areas));
Expand All @@ -56,10 +46,6 @@ export async function fetch(
delay(wait),
window.dispatchEvent(new Event('pjax:fetch')),
]);
if (type === RouterEventType.Popstate) {
style.parentNode?.removeChild(style);
window.scrollTo(scrollX, scrollY);
}
return res
.bind(process.either)
.fmap(res => [res, seq] as const);
Expand Down

0 comments on commit 6130a0d

Please sign in to comment.