fix: removed unpublish button

This commit is contained in:
2026-02-11 16:14:41 +01:00
parent 11ec82d12e
commit 258e313f0e
6 changed files with 1 additions and 88 deletions

View File

@@ -948,57 +948,6 @@ export class PostEngine extends EventEmitter {
return !!(dbPost && dbPost.filePath && dbPost.filePath !== '');
}
async unpublishPost(id: string): Promise<PostData | null> {
const db = getDatabase().getLocal();
const client = getDatabase().getLocalClient();
const existing = await this.getPost(id);
if (!existing) {
return null;
}
const dbPost = await db.select().from(posts).where(eq(posts.id, id)).get();
if (!dbPost) {
return null;
}
// Delete the published file (content moves to DB)
if (dbPost.filePath) {
try {
await fs.unlink(dbPost.filePath);
} catch {
// File might not exist
}
}
const updated: PostData = {
...existing,
status: 'draft',
updatedAt: new Date(),
};
const checksum = this.calculateChecksum(updated.content);
// Store content in DB, clear filePath
await db.update(posts)
.set({
content: updated.content,
status: 'draft',
filePath: '',
updatedAt: updated.updatedAt,
publishedAt: null,
syncStatus: 'pending',
checksum,
})
.where(eq(posts.id, id));
// Update FTS index
await this.updateFTSIndex(updated);
this.emit('postUpdated', updated);
return updated;
}
/**
* Rebuild the FTS index for all posts in the current project.
* Call this after changing the search language or after migration.

View File

@@ -135,11 +135,6 @@ export function registerIpcHandlers(): void {
return engine.publishPost(id);
});
ipcMain.handle('posts:unpublish', async (_, id: string) => {
const engine = getPostEngine();
return engine.unpublishPost(id);
});
ipcMain.handle('posts:discard', async (_, id: string) => {
const engine = getPostEngine();
return engine.discardChanges(id);

View File

@@ -24,7 +24,6 @@ contextBridge.exposeInMainWorld('electronAPI', {
getAll: (options?: { limit?: number; offset?: number }) => ipcRenderer.invoke('posts:getAll', options),
getByStatus: (status: string) => ipcRenderer.invoke('posts:getByStatus', status),
publish: (id: string) => ipcRenderer.invoke('posts:publish', id),
unpublish: (id: string) => ipcRenderer.invoke('posts:unpublish', id),
discard: (id: string) => ipcRenderer.invoke('posts:discard', id),
hasPublishedVersion: (id: string) => ipcRenderer.invoke('posts:hasPublishedVersion', id),
rebuildFromFiles: () => ipcRenderer.invoke('posts:rebuildFromFiles'),