BLOG-126 Post management (list and create) #139

Merged
squid merged 10 commits from BLOG-126_post_management into main 2025-10-15 04:21:15 +08:00
4 changed files with 8 additions and 30 deletions
Showing only changes of commit 063374f56f - Show all commits

View File

@ -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);
});

View File

@ -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<AuthViewModel>;
export type AuthEvent = CurrentUserLoadedEvent;
export class AuthBloc {
private readonly state = writable<AuthState>({
status: StatusType.Idle,
});
private readonly state = writable<AuthState>(StateFactory.idle());
constructor(private readonly getCurrentUserUseCase: GetCurrentUserUseCase) {}

View File

@ -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<ImageInfoViewModel>;
export type ImageEvent = ImageUploadedEvent;
export class ImageBloc {
private readonly state = writable<ImageInfoState>({
status: StatusType.Idle,
});
private readonly state = writable<ImageInfoState>(StateFactory.idle());
constructor(private readonly uploadImageUseCase: UploadImageUseCase) {}

View File

@ -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<PostViewModel>;
export type PostEvent = PostLoadedEvent | PostCreatedEvent;
export class PostBloc {
private readonly state = writable<PostState>({
status: StatusType.Idle,
});
private readonly state = writable<PostState>(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() {