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