Add support for deleting a shared preference (#1018)
Summary: This change makes it possible to remove preferences. I also added a `Delete` context menu option to `DataInspector` because I needed it to implement this feature. passy confirmed that it makes sense to add this because delete is a common action. Fixes https://github.com/facebook/flipper/issues/451 Pull Request resolved: https://github.com/facebook/flipper/pull/1018 Reviewed By: jknoxville Differential Revision: D21086308 Pulled By: passy fbshipit-source-id: 551ff0908d5e6c93f58d6012b42e1ee3531de997
This commit is contained in:
committed by
Facebook GitHub Bot
parent
9b8974eeb3
commit
2d1870cf7d
@@ -209,6 +209,21 @@ export default class extends FlipperPlugin<SharedPreferencesState> {
|
||||
});
|
||||
};
|
||||
|
||||
onSharedPreferencesDeleted = (path: Array<string>) => {
|
||||
this.client
|
||||
.call('deleteSharedPreference', {
|
||||
sharedPreferencesName: this.state.selectedPreferences,
|
||||
preferenceName: path[0],
|
||||
})
|
||||
.then((results: SharedPreferences) => {
|
||||
const update = {
|
||||
name: this.state.selectedPreferences,
|
||||
preferences: results,
|
||||
};
|
||||
this.dispatchAction({update, type: 'UpdateSharedPreferences'});
|
||||
});
|
||||
};
|
||||
|
||||
render() {
|
||||
const selectedPreferences = this.state.selectedPreferences;
|
||||
if (selectedPreferences == null) {
|
||||
@@ -241,6 +256,7 @@ export default class extends FlipperPlugin<SharedPreferencesState> {
|
||||
<ManagedDataInspector
|
||||
data={entry.preferences}
|
||||
setValue={this.onSharedPreferencesChanged}
|
||||
onDelete={this.onSharedPreferencesDeleted}
|
||||
/>
|
||||
</InspectorColumn>
|
||||
<ChangelogColumn>
|
||||
|
||||
Reference in New Issue
Block a user