chore: last refactors finished

This commit is contained in:
2026-02-21 18:29:25 +01:00
parent f9663b07b1
commit 3fb0085b11
6 changed files with 196 additions and 286 deletions

View File

@@ -0,0 +1,33 @@
export interface CreateAndFocusPostOptions {
createPost: (input: {
title: string;
content: string;
tags: string[];
categories: string[];
}) => Promise<{ id: string } | null | undefined>;
setSelectedPost: (postId: string) => void;
ensurePostsSidebar?: () => void;
onError?: (error: unknown) => void;
}
export async function createAndFocusPost(options: CreateAndFocusPostOptions): Promise<string | null> {
try {
const post = await options.createPost({
title: '',
content: '',
tags: [],
categories: [],
});
if (!post) {
return null;
}
options.setSelectedPost(post.id);
options.ensurePostsSidebar?.();
return post.id;
} catch (error) {
options.onError?.(error);
return null;
}
}