From 20d7c19670380a3a1c912e429209d08643eaa306 Mon Sep 17 00:00:00 2001 From: Rajat Dabade Date: Fri, 21 Feb 2025 12:44:03 +0530 Subject: [PATCH] review fixes --- app/actions/remote/scheduled_post.test.ts | 8 ++++---- app/actions/remote/scheduled_post.ts | 6 +----- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/app/actions/remote/scheduled_post.test.ts b/app/actions/remote/scheduled_post.test.ts index de9d632cfe..525d402998 100644 --- a/app/actions/remote/scheduled_post.test.ts +++ b/app/actions/remote/scheduled_post.test.ts @@ -172,10 +172,10 @@ describe('fetchScheduledPosts', () => { describe('updateScheduledPost', () => { it('update Schedule post - handle not found database', async () => { - const result = await updateScheduledPost('foo', scheduledPost); - expect(result.error).toBe('foo database not found'); - expect(logError).not.toHaveBeenCalled(); - expect(forceLogoutIfNecessary).not.toHaveBeenCalled(); + const result = await updateScheduledPost('foo', scheduledPost) as unknown as {error: Error}; + expect(result).toEqual({error: 'foo database not found'}); + expect(logError).toHaveBeenCalled(); + expect(forceLogoutIfNecessary).toHaveBeenCalled(); }); it('update Schedule post - base case', async () => { diff --git a/app/actions/remote/scheduled_post.ts b/app/actions/remote/scheduled_post.ts index 6917d20222..70af925725 100644 --- a/app/actions/remote/scheduled_post.ts +++ b/app/actions/remote/scheduled_post.ts @@ -40,12 +40,8 @@ export async function createScheduledPost(serverUrl: string, schedulePost: Sched } export async function updateScheduledPost(serverUrl: string, scheduledPost: ScheduledPost, connectionId?: string, fetchOnly = false) { - const operator = DatabaseManager.serverDatabases[serverUrl]?.operator; - if (!operator) { - return {error: `${serverUrl} database not found`}; - } - try { + const {operator} = DatabaseManager.getServerDatabaseAndOperator(serverUrl); const client = NetworkManager.getClient(serverUrl); const response = await client.updateScheduledPost(scheduledPost, connectionId);