From f49745448c6e39b8ed09e5f6554a3ef733feef89 Mon Sep 17 00:00:00 2001 From: Pritesh Nandgaonkar Date: Tue, 29 Oct 2019 13:41:44 -0700 Subject: [PATCH] Pass the status Msg as an argument Summary: Before this diff whenever one called serialize method it showed `Serializing Flipper ` msg without showing the explicit details of which data we are serializing. Thus with this diff one can pass the status msg as an argument which will be displayed while serializing. Reviewed By: jknoxville Differential Revision: D18173024 fbshipit-source-id: a4e7e073498993626204061d4e774099f00b8c5a --- src/plugin.tsx | 9 ++++++++- src/utils/exportData.tsx | 1 + src/utils/serialization.tsx | 7 +++++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/plugin.tsx b/src/plugin.tsx index 3105d519a..d2939662c 100644 --- a/src/plugin.tsx +++ b/src/plugin.tsx @@ -140,12 +140,19 @@ export abstract class FlipperBasePlugin< persistedState: StaticPersistedState, statusUpdate?: (msg: string) => void, idler?: Idler, + pluginName?: string, ) => Promise = ( persistedState: StaticPersistedState, statusUpdate?: (msg: string) => void, idler?: Idler, + pluginName?: string, ) => { - return serialize(persistedState, idler, statusUpdate); + return serialize( + persistedState, + idler, + statusUpdate, + pluginName != null ? `Serializing ${pluginName}` : undefined, + ); }; static deserializePersistedState: ( serializedString: string, diff --git a/src/utils/exportData.tsx b/src/utils/exportData.tsx index 9f1962384..7a213bee6 100644 --- a/src/utils/exportData.tsx +++ b/src/utils/exportData.tsx @@ -200,6 +200,7 @@ const serializePluginStates = async ( pluginStates[key], statusUpdate, idler, + pluginName, ); } } diff --git a/src/utils/serialization.tsx b/src/utils/serialization.tsx index e8cb04487..569c44eb2 100644 --- a/src/utils/serialization.tsx +++ b/src/utils/serialization.tsx @@ -12,8 +12,9 @@ export async function serialize( obj: Object, idler?: Idler, statusUpdate?: (msg: string) => void, + statusMsg?: string, ): Promise { - return makeObjectSerializable(obj, idler, statusUpdate).then(obj => + return makeObjectSerializable(obj, idler, statusUpdate, statusMsg).then(obj => JSON.stringify(obj), ); } @@ -124,6 +125,7 @@ export async function makeObjectSerializable( obj: any, idler?: Idler, statusUpdate?: (msg: string) => void, + statusMsg?: string, ): Promise { if (!(obj instanceof Object)) { return obj; @@ -199,7 +201,8 @@ export async function makeObjectSerializable( const percentage = (numIterations / accumulator) * 100; statusUpdate && statusUpdate( - `Serializing Flipper: ${numIterations} / ${accumulator} (${percentage.toFixed( + `${statusMsg || + 'Serializing Flipper '}: ${numIterations} / ${accumulator} (${percentage.toFixed( 2, )}%) `, );