diff --git a/frontend/src/hooks.server.ts b/frontend/src/hooks.server.ts index e1e1b4e..17a5c14 100644 --- a/frontend/src/hooks.server.ts +++ b/frontend/src/hooks.server.ts @@ -11,8 +11,7 @@ Sentry.init({ }); export const handle: Handle = sequence(Sentry.sentryHandle(), ({ event, resolve }) => { - const container = new Container(event.fetch); - event.locals.container = container; + event.locals.container ??= new Container(event.fetch); return resolve(event); }); diff --git a/frontend/src/lib/auth/adapter/presenter/authBloc.ts b/frontend/src/lib/auth/adapter/presenter/authBloc.ts index 1d1c7d8..bc97472 100644 --- a/frontend/src/lib/auth/adapter/presenter/authBloc.ts +++ b/frontend/src/lib/auth/adapter/presenter/authBloc.ts @@ -1,11 +1,7 @@ import { AuthViewModel } from '$lib/auth/adapter/presenter/authViewModel'; import { UserViewModel } from '$lib/auth/adapter/presenter/userViewModel'; import type { GetCurrentUserUseCase } from '$lib/auth/application/useCase/getCurrentUserUseCase'; -import { - StateFactory, - StatusType, - type AsyncState, -} from '$lib/common/adapter/presenter/asyncState'; +import { StateFactory, type AsyncState } from '$lib/common/adapter/presenter/asyncState'; import { captureException } from '@sentry/sveltekit'; import { get, writable } from 'svelte/store'; @@ -13,9 +9,7 @@ export type AuthState = AsyncState; export type AuthEvent = CurrentUserLoadedEvent; export class AuthBloc { - private readonly state = writable({ - status: StatusType.Idle, - }); + private readonly state = writable(StateFactory.idle()); constructor(private readonly getCurrentUserUseCase: GetCurrentUserUseCase) {} diff --git a/frontend/src/lib/image/adapter/presenter/imageBloc.ts b/frontend/src/lib/image/adapter/presenter/imageBloc.ts index ee44433..77f333e 100644 --- a/frontend/src/lib/image/adapter/presenter/imageBloc.ts +++ b/frontend/src/lib/image/adapter/presenter/imageBloc.ts @@ -1,8 +1,4 @@ -import { - StateFactory, - StatusType, - type AsyncState, -} from '$lib/common/adapter/presenter/asyncState'; +import { StateFactory, type AsyncState } from '$lib/common/adapter/presenter/asyncState'; import { ImageInfoViewModel } from '$lib/image/adapter/presenter/imageInfoViewModel'; import type { UploadImageUseCase } from '$lib/image/application/useCase/uploadImageUseCase'; import { captureException } from '@sentry/sveltekit'; @@ -12,9 +8,7 @@ export type ImageInfoState = AsyncState; export type ImageEvent = ImageUploadedEvent; export class ImageBloc { - private readonly state = writable({ - status: StatusType.Idle, - }); + private readonly state = writable(StateFactory.idle()); constructor(private readonly uploadImageUseCase: UploadImageUseCase) {} diff --git a/frontend/src/lib/post/adapter/presenter/postBloc.ts b/frontend/src/lib/post/adapter/presenter/postBloc.ts index 1b867f7..83156b5 100644 --- a/frontend/src/lib/post/adapter/presenter/postBloc.ts +++ b/frontend/src/lib/post/adapter/presenter/postBloc.ts @@ -1,8 +1,4 @@ -import { - StateFactory, - StatusType, - type AsyncState, -} from '$lib/common/adapter/presenter/asyncState'; +import { StateFactory, type AsyncState } from '$lib/common/adapter/presenter/asyncState'; import { PostViewModel } from '$lib/post/adapter/presenter/postViewModel'; import type { CreatePostParams } from '$lib/post/application/gateway/postRepository'; import type { CreatePostUseCase } from '$lib/post/application/useCase/createPostUseCase'; @@ -14,19 +10,14 @@ export type PostState = AsyncState; export type PostEvent = PostLoadedEvent | PostCreatedEvent; export class PostBloc { - private readonly state = writable({ - status: StatusType.Idle, - }); + private readonly state = writable(StateFactory.idle()); constructor( private readonly getPostUseCase: GetPostUseCase, private readonly createPostUseCase: CreatePostUseCase, initialData?: PostViewModel ) { - this.state.set({ - status: StatusType.Idle, - data: initialData, - }); + this.state.set(StateFactory.idle(initialData)); } get subscribe() {