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