From ceb9d742c9decec95f360c6c58efe5eef481deda Mon Sep 17 00:00:00 2001 From: Scott Bishel Date: Tue, 23 Jan 2024 12:14:12 -0700 Subject: [PATCH] add paging for preferences to match new server limitation --- app/actions/remote/preference.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/actions/remote/preference.ts b/app/actions/remote/preference.ts index 5e390efea..27782cb99 100644 --- a/app/actions/remote/preference.ts +++ b/app/actions/remote/preference.ts @@ -2,6 +2,7 @@ // See LICENSE.txt for license information. import {DeviceEventEmitter} from 'react-native'; +import {chunk} from 'lodash'; import {handleReconnect} from '@actions/websocket'; import {Events, General, Preferences} from '@constants'; @@ -93,7 +94,11 @@ export const savePreference = async (serverUrl: string, preferences: PreferenceT const {database, operator} = DatabaseManager.getServerDatabaseAndOperator(serverUrl); const userId = await getCurrentUserId(database); - client.savePreferences(userId, preferences); + const chunkSize = 100; + const chunks = chunk(preferences, chunkSize); + chunks.forEach((chunk: PreferenceType[]) => { + client.savePreferences(userId, chunk); + }); const preferenceModels = await operator.handlePreferences({ preferences, prepareRecordsOnly,