@@ -220,13 +220,13 @@ internal override bool IsKeyMutable(string key) {
220
220
internal override Task SaveAsync ( Task toAwait , CancellationToken cancellationToken ) {
221
221
Task platformHookTask = null ;
222
222
if ( CurrentInstallationController . IsCurrent ( this ) ) {
223
- SetIfDifferent ( "deviceType" , ParseClient . PlatformHooks . DeviceType ) ;
224
- SetIfDifferent ( "timeZone" , ParseClient . PlatformHooks . DeviceTimeZone ) ;
225
- SetIfDifferent ( "localeIdentifier" , GetLocaleIdentifier ( ) ) ;
226
- SetIfDifferent ( "parseVersion" , GetParseVersion ( ) . ToString ( ) ) ;
227
- SetIfDifferent ( "appVersion" , ParseClient . PlatformHooks . AppBuildVersion ) ;
228
- SetIfDifferent ( "appIdentifier" , ParseClient . PlatformHooks . AppIdentifier ) ;
229
- SetIfDifferent ( "appName" , ParseClient . PlatformHooks . AppName ) ;
223
+ ForceSetIfDifferent ( "deviceType" , ParseClient . PlatformHooks . DeviceType ) ;
224
+ ForceSetIfDifferent ( "timeZone" , ParseClient . PlatformHooks . DeviceTimeZone ) ;
225
+ ForceSetIfDifferent ( "localeIdentifier" , GetLocaleIdentifier ( ) ) ;
226
+ ForceSetIfDifferent ( "parseVersion" , GetParseVersion ( ) . ToString ( ) ) ;
227
+ ForceSetIfDifferent ( "appVersion" , ParseClient . PlatformHooks . AppBuildVersion ) ;
228
+ ForceSetIfDifferent ( "appIdentifier" , ParseClient . PlatformHooks . AppIdentifier ) ;
229
+ ForceSetIfDifferent ( "appName" , ParseClient . PlatformHooks . AppName ) ;
230
230
231
231
// TODO (hallucinogen): this probably should have been a controller.
232
232
platformHookTask = ParseClient . PlatformHooks . ExecuteParseInstallationSaveHookAsync ( this ) ;
@@ -241,6 +241,25 @@ internal override Task SaveAsync(Task toAwait, CancellationToken cancellationTok
241
241
}
242
242
return CurrentInstallationController . SetAsync ( this , cancellationToken ) ;
243
243
} ) . Unwrap ( ) ;
244
+ }
245
+
246
+ /// <summary>
247
+ /// We need this to set a key irrespective of the 'IsKeyMutable' function.
248
+ /// </summary>
249
+ /// <param name="key">Key to update</param>
250
+ /// <param name="value">New value to set</param>
251
+ private void ForceSetIfDifferent ( string key , object value ) {
252
+ lock ( mutex ) {
253
+ // Check if the value has changed.
254
+ object currentValue = this [ key ] ;
255
+ if ( Object . ReferenceEquals ( currentValue , value ) ||
256
+ ( currentValue != null && currentValue . Equals ( value ) ) ) {
257
+ // No change in value.
258
+ return ;
259
+ }
260
+
261
+ PerformOperation ( key , new ParseSetOperation ( value ) ) ;
262
+ }
244
263
}
245
264
246
265
/// <summary>
0 commit comments