diff --git a/app/actions/remote/post.ts b/app/actions/remote/post.ts index 8f80cf53e..342478896 100644 --- a/app/actions/remote/post.ts +++ b/app/actions/remote/post.ts @@ -454,7 +454,7 @@ export async function fetchPostsSince(serverUrl: string, channelId: string, sinc const isCRTEnabled = await getIsCRTEnabled(database); const data = await client.getPostsSince(channelId, since, isCRTEnabled, isCRTEnabled); - const result = await processPostsFetched(data); + const result = processPostsFetched(data); if (!fetchOnly) { const models = await operator.handlePosts({ ...result, diff --git a/app/products/calls/actions/calls.ts b/app/products/calls/actions/calls.ts index fb5f5b009..1b851f87e 100644 --- a/app/products/calls/actions/calls.ts +++ b/app/products/calls/actions/calls.ts @@ -524,7 +524,7 @@ export const handleCallsSlashCommand = async (value: string, serverUrl: string, } case 'leave': if (getCurrentCall()?.channelId === channelId) { - await leaveCall(); + leaveCall(); return {handled: true}; } return { diff --git a/app/products/calls/alerts.ts b/app/products/calls/alerts.ts index 20007e4fa..092e20c40 100644 --- a/app/products/calls/alerts.ts +++ b/app/products/calls/alerts.ts @@ -310,7 +310,7 @@ export const recordingAlert = (isHost: boolean, transcriptionsEnabled: boolean, defaultMessage: 'Leave', }), onPress: async () => { - await leaveCall(); + leaveCall(); }, style: 'destructive', }, diff --git a/app/utils/apps.test.ts b/app/utils/apps.test.ts index 767e5a015..1f2fe6225 100644 --- a/app/utils/apps.test.ts +++ b/app/utils/apps.test.ts @@ -40,9 +40,9 @@ describe('cleanBinding', () => { }; const result = cleanBinding(binding, AppBindingLocations.COMMAND); - expect(result.bindings![0].app_id).toBe('test_app'); - expect(result.bindings![0].label).toBeTruthy(); - expect(result.bindings![0].location).toMatch(/location\/.+/); + expect(result!.bindings![0].app_id).toBe('test_app'); + expect(result!.bindings![0].label).toBeTruthy(); + expect(result!.bindings![0].location).toMatch(/location\/.+/); }); it('should remove bindings without app_id', () => { @@ -70,8 +70,8 @@ describe('cleanBinding', () => { }; const result = cleanBinding(binding, AppBindingLocations.COMMAND); - expect(result.bindings).toHaveLength(1); - expect(result.bindings![0].app_id).toBe('sub_app'); + expect(result!.bindings).toHaveLength(1); + expect(result!.bindings![0].app_id).toBe('sub_app'); }); it('should remove bindings with empty or whitespace labels', () => { @@ -109,8 +109,8 @@ describe('cleanBinding', () => { }; const result = cleanBinding(binding, AppBindingLocations.COMMAND); - expect(result.bindings).toHaveLength(1); - expect(result.bindings![0].label).toBe('valid_label'); + expect(result!.bindings).toHaveLength(1); + expect(result!.bindings![0].label).toBe('valid_label'); }); it('should remove bindings with duplicate labels in COMMAND location', () => { @@ -143,8 +143,8 @@ describe('cleanBinding', () => { }; const result = cleanBinding(binding, AppBindingLocations.COMMAND); - expect(result.bindings).toHaveLength(1); - expect(result.bindings![0].app_id).toBe('sub_app1'); + expect(result!.bindings).toHaveLength(1); + expect(result!.bindings![0].app_id).toBe('sub_app1'); }); it('should keep unique labels in IN_POST location', () => { @@ -177,7 +177,7 @@ describe('cleanBinding', () => { }; const result = cleanBinding(binding, AppBindingLocations.IN_POST); - expect(result.bindings).toHaveLength(2); + expect(result!.bindings).toHaveLength(2); }); it('should remove invalid sub-bindings without form or submit', () => { @@ -213,9 +213,9 @@ describe('cleanBinding', () => { }; const result = cleanBinding(binding, AppBindingLocations.COMMAND); - expect(result.bindings).toHaveLength(2); - expect(result.bindings![0].label).toBe('sub_label2'); - expect(result.bindings![1].label).toBe('sub_label3'); + expect(result!.bindings).toHaveLength(2); + expect(result!.bindings![0].label).toBe('sub_label2'); + expect(result!.bindings![1].label).toBe('sub_label3'); }); it('should handle forms correctly', () => { @@ -238,8 +238,8 @@ describe('cleanBinding', () => { }; const result = cleanBinding(binding, AppBindingLocations.COMMAND); - expect(result.bindings).toHaveLength(1); - expect(result.bindings![0].form).toBeTruthy(); + expect(result!.bindings).toHaveLength(1); + expect(result!.bindings![0].form).toBeTruthy(); }); it('should handle submit calls correctly', () => { @@ -260,8 +260,8 @@ describe('cleanBinding', () => { }; const result = cleanBinding(binding, AppBindingLocations.COMMAND); - expect(result.bindings).toHaveLength(1); - expect(result.bindings![0].submit).toBeTruthy(); + expect(result!.bindings).toHaveLength(1); + expect(result!.bindings![0].submit).toBeTruthy(); }); it('should recursively clean sub-bindings', () => { @@ -296,9 +296,9 @@ describe('cleanBinding', () => { }; const result = cleanBinding(binding, AppBindingLocations.COMMAND); - expect(result.bindings).toHaveLength(1); - expect(result.bindings![0].bindings).toHaveLength(1); - expect(result.bindings![0].bindings![0].label).toBe('sub_sub_label'); + expect(result!.bindings).toHaveLength(1); + expect(result!.bindings![0].bindings).toHaveLength(1); + expect(result!.bindings![0].bindings![0].label).toBe('sub_sub_label'); }); it('should handle bindings without bindings, form, or submit', () => { @@ -316,7 +316,7 @@ describe('cleanBinding', () => { }; const result = cleanBinding(binding, AppBindingLocations.COMMAND); - expect(result.bindings).toHaveLength(0); + expect(result!.bindings).toHaveLength(0); }); it('should handle multiple levels of nested bindings correctly', () => { @@ -361,10 +361,10 @@ describe('cleanBinding', () => { }; const result = cleanBinding(binding, AppBindingLocations.COMMAND); - expect(result.bindings).toHaveLength(2); - expect(result.bindings![0].bindings).toHaveLength(1); - expect(result.bindings![0].bindings![0].label).toBe('sub_sub_label'); - expect(result.bindings![1].label).toBe('sub_label2'); + expect(result!.bindings).toHaveLength(2); + expect(result!.bindings![0].bindings).toHaveLength(1); + expect(result!.bindings![0].bindings![0].label).toBe('sub_sub_label'); + expect(result!.bindings![1].label).toBe('sub_label2'); }); }); diff --git a/app/utils/apps.ts b/app/utils/apps.ts index 2605efd7c..bd21068c6 100644 --- a/app/utils/apps.ts +++ b/app/utils/apps.ts @@ -5,13 +5,13 @@ import {AppBindingLocations, AppCallResponseTypes, AppFieldTypes} from '@constan import {generateId} from './general'; -export function cleanBinding(binding: AppBinding, topLocation: string): AppBinding { +export function cleanBinding(binding: AppBinding, topLocation: string): AppBinding|null { return cleanBindingRec(binding, topLocation, 0); } -function cleanBindingRec(binding: AppBinding, topLocation: string, depth: number): AppBinding { +function cleanBindingRec(binding: AppBinding, topLocation: string, depth: number): AppBinding|null { if (!binding) { - return binding; + return null; } const toRemove: number[] = []; diff --git a/app/utils/helpers.ts b/app/utils/helpers.ts index 67a2ac238..f654063aa 100644 --- a/app/utils/helpers.ts +++ b/app/utils/helpers.ts @@ -164,6 +164,10 @@ export function isMainActivity() { return true; } +function localeCompare(a: string, b: string) { + return a.localeCompare(b); +} + export function areBothStringArraysEqual(a: string[], b: string[]) { if (a.length !== b.length) { return false; @@ -173,8 +177,8 @@ export function areBothStringArraysEqual(a: string[], b: string[]) { return false; } - const aSorted = a.sort(); - const bSorted = b.sort(); + const aSorted = a.sort(localeCompare); + const bSorted = b.sort(localeCompare); const areBothEqual = aSorted.every((value, index) => value === bSorted[index]); return areBothEqual; diff --git a/app/utils/url/test.ts b/app/utils/url/test.ts index ba78b5a0c..bdb16205a 100644 --- a/app/utils/url/test.ts +++ b/app/utils/url/test.ts @@ -437,7 +437,8 @@ describe('UrlUtils', () => { const onError = jest.fn(); const onSuccess = jest.fn(); - await UrlUtils.tryOpenURL(url, onError, onSuccess); + UrlUtils.tryOpenURL(url, onError, onSuccess); + await TestHelper.wait(100); expect(onError).not.toHaveBeenCalled(); expect(onSuccess).toHaveBeenCalledTimes(1); });