MOBILE-4031 user: Fix error updating preference in offline
parent
195c2af178
commit
ace9256d26
|
@ -86,5 +86,5 @@ export type CoreUserDBRecord = CoreUserBasicData;
|
|||
export type CoreUserPreferenceDBRecord = {
|
||||
name: string;
|
||||
value: string;
|
||||
onlinevalue: string;
|
||||
onlinevalue: string | null;
|
||||
};
|
||||
|
|
|
@ -58,19 +58,12 @@ export class CoreUserOfflineProvider {
|
|||
* @param siteId Site ID. If not defined, current site.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
async setPreference(name: string, value: string, onlineValue?: string, siteId?: string): Promise<void> {
|
||||
async setPreference(name: string, value: string, onlineValue?: string | null , siteId?: string): Promise<void> {
|
||||
const site = await CoreSites.getSite(siteId);
|
||||
|
||||
if (onlineValue === undefined) {
|
||||
const preference = await this.getPreference(name, site.id);
|
||||
|
||||
onlineValue = preference.onlinevalue;
|
||||
}
|
||||
|
||||
const record: CoreUserPreferenceDBRecord = {
|
||||
const record: Partial<CoreUserPreferenceDBRecord> = {
|
||||
name,
|
||||
value,
|
||||
onlinevalue: onlineValue,
|
||||
};
|
||||
|
||||
await site.getDb().insertRecord(PREFERENCES_TABLE_NAME, record);
|
||||
|
|
|
@ -1106,7 +1106,7 @@ type CoreUserGetUserPreferencesWSParams = {
|
|||
type CoreUserGetUserPreferencesWSResponse = {
|
||||
preferences: { // User custom fields (also known as user profile fields).
|
||||
name: string; // The name of the preference.
|
||||
value: string; // The value of the preference.
|
||||
value: string | null; // The value of the preference.
|
||||
}[];
|
||||
warnings?: CoreWSExternalWarning[];
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue