fix: better handling of many posts

This commit is contained in:
2026-02-10 22:48:13 +01:00
parent 7e4457c15d
commit 6bbf13dd41
10 changed files with 285 additions and 24 deletions

View File

@@ -1,6 +1,6 @@
import { ipcMain, dialog, shell } from 'electron';
import { eq } from 'drizzle-orm';
import { getPostEngine, PostData, PostFilter } from '../engine/PostEngine';
import { getPostEngine, PostData, PostFilter, PaginationOptions } from '../engine/PostEngine';
import { getMediaEngine, MediaData } from '../engine/MediaEngine';
import { getSyncEngine, SyncConfig, SyncDirection } from '../engine/SyncEngine';
import { getDropboxSyncEngine, DropboxSyncConfig, ConflictResolution } from '../engine/DropboxSyncEngine';
@@ -99,9 +99,9 @@ export function registerIpcHandlers(): void {
return engine.getPost(id);
});
ipcMain.handle('posts:getAll', async () => {
ipcMain.handle('posts:getAll', async (_, options?: PaginationOptions) => {
const engine = getPostEngine();
return engine.getAllPosts();
return engine.getAllPosts(options);
});
ipcMain.handle('posts:getByStatus', async (_, status: 'draft' | 'published' | 'archived') => {
@@ -231,6 +231,18 @@ export function registerIpcHandlers(): void {
return engine.getMedia(id);
});
ipcMain.handle('media:getUrl', async (_, id: string) => {
// Returns the bds-media:// protocol URL for a media item
return `bds-media://${id}`;
});
ipcMain.handle('media:getFilePath', async (_, id: string) => {
// Returns the actual file path for a media item (for debugging/advanced use)
const db = getDatabase().getLocal();
const mediaItem = await db.select().from(media).where(eq(media.id, id)).get();
return mediaItem?.filePath ?? null;
});
ipcMain.handle('media:getAll', async () => {
const engine = getMediaEngine();
return engine.getAllMedia();