From dcc41ad17b4c6d8678a23c5560fc1a5c62c44a3a Mon Sep 17 00:00:00 2001 From: Federico Mastrini Date: Tue, 17 Dec 2024 12:46:32 +0100 Subject: [PATCH] chore: avoid to show undefined debug data in debug info overlay --- ts/store/reducers/debug.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/ts/store/reducers/debug.ts b/ts/store/reducers/debug.ts index 79b127ba1ac..5153d1837e6 100644 --- a/ts/store/reducers/debug.ts +++ b/ts/store/reducers/debug.ts @@ -1,5 +1,6 @@ import AsyncStorage from "@react-native-async-storage/async-storage"; import { PersistConfig, PersistPartial, persistReducer } from "redux-persist"; +import { createSelector } from "reselect"; import { getType } from "typesafe-actions"; import { resetDebugData, @@ -73,4 +74,15 @@ export const debugPersistor = persistReducer( // Selector export const isDebugModeEnabledSelector = (state: GlobalState) => state.debug.isDebugModeEnabled; -export const debugDataSelector = (state: GlobalState) => state.debug.debugData; + +/** + * Selector that returns the debug data without the undefined values + * avoiding to display empty values in the DebugInfoOverlay + */ +export const debugDataSelector = createSelector( + (state: GlobalState) => state.debug.debugData, + debugData => + Object.fromEntries( + Object.entries(debugData).filter(([_, value]) => value !== undefined) + ) +);