Skip to content

Commit e60b35b

Browse files
mcayuelas-ledgerhedi-edelbloute
authored andcommitted
feat(LLD): Update modelListId with unique device type (#3766)
* feat(LLD): Update modelListId with unique device type * Update Changeset
1 parent b3eb46f commit e60b35b

File tree

6 files changed

+19
-17
lines changed

6 files changed

+19
-17
lines changed

.changeset/chilled-timers-remember.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
"ledger-live-desktop": patch
33
---
44

5-
LLD - Add modelIdList user property and event property
5+
LLD - Add modelIdList user property and event property. The list will be: [ "nanoX", "stax", "nanoS"]

apps/ledger-live-desktop/src/renderer/actions/settings.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,9 +283,9 @@ export const setLastSeenDevice = ({ deviceInfo }: { deviceInfo: DeviceInfo }) =>
283283
},
284284
});
285285

286-
export const addNewDevice = ({ seenDevice }: { seenDevice: DeviceModelInfo }) => ({
287-
type: "ADD_SEEN_DEVICE",
288-
payload: seenDevice,
286+
export const addNewDeviceModel = ({ deviceModelId }: { deviceModelId: DeviceModelId }) => ({
287+
type: "ADD_NEW_DEVICE_MODEL",
288+
payload: deviceModelId,
289289
});
290290
export const setDeepLinkUrl = (url?: string | null) => ({
291291
type: "SET_DEEPLINK_URL",

apps/ledger-live-desktop/src/renderer/analytics/segment.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
lastSeenDeviceSelector,
1212
localeSelector,
1313
languageSelector,
14-
seenDevicesSelector,
14+
devicesModelListSelector,
1515
} from "~/renderer/reducers/settings";
1616
import { State } from "~/renderer/reducers";
1717
import { AccountLike, idsToLanguage } from "@ledgerhq/types-live";
@@ -51,7 +51,7 @@ const extraProperties = (store: ReduxStore) => {
5151
const region = (localeSelector(state).split("-")[1] || "").toUpperCase() || null;
5252
const systemLocale = getParsedSystemLocale();
5353
const device = lastSeenDeviceSelector(state);
54-
const devices = seenDevicesSelector(state);
54+
const devices = devicesModelListSelector(state);
5555
const accounts = accountsSelector(state);
5656
const deviceInfo = device
5757
? {
@@ -100,7 +100,7 @@ const extraProperties = (store: ReduxStore) => {
100100
blockchainsWithNftsOwned,
101101
hasGenesisPass,
102102
hasInfinityPass,
103-
modelIdList: devices.map(d => d.modelId),
103+
modelIdList: devices,
104104
...deviceInfo,
105105
};
106106
};

apps/ledger-live-desktop/src/renderer/components/DeviceAction/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { getCurrentDevice } from "~/renderer/reducers/devices";
1616
import {
1717
setPreferredDeviceModel,
1818
setLastSeenDeviceInfo,
19-
addNewDevice,
19+
addNewDeviceModel,
2020
} from "~/renderer/actions/settings";
2121
import { preferredDeviceModelSelector } from "~/renderer/reducers/settings";
2222
import { DeviceModelId } from "@ledgerhq/devices";
@@ -245,7 +245,7 @@ export const DeviceActionDefaultRendering = <R, H extends States, P>({
245245
apps: [],
246246
};
247247
dispatch(setLastSeenDeviceInfo({ lastSeenDevice, latestFirmware }));
248-
dispatch(addNewDevice({ seenDevice: lastSeenDevice }));
248+
dispatch(addNewDeviceModel({ deviceModelId: lastSeenDevice.modelId }));
249249
}
250250
}, [dispatch, device, deviceInfo, latestFirmware]);
251251

apps/ledger-live-desktop/src/renderer/reducers/settings.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export type SettingsState = {
3232
preferredDeviceModel: DeviceModelId;
3333
hasInstalledApps: boolean;
3434
lastSeenDevice: DeviceModelInfo | undefined | null;
35-
seenDevices: DeviceModelInfo[];
35+
devicesModelList: DeviceModelId[];
3636
latestFirmware: FirmwareUpdateContext | null;
3737
language: string | undefined | null;
3838
theme: string | undefined | null;
@@ -142,7 +142,7 @@ const INITIAL_STATE: SettingsState = {
142142
hasInstalledApps: true,
143143
carouselVisibility: 0,
144144
lastSeenDevice: null,
145-
seenDevices: [],
145+
devicesModelList: [],
146146
lastSeenCustomImage: {
147147
size: 0,
148148
hash: "",
@@ -192,7 +192,7 @@ type HandlersPayloads = {
192192
latestFirmware: FirmwareUpdateContext;
193193
};
194194
LAST_SEEN_DEVICE: DeviceModelInfo;
195-
ADD_SEEN_DEVICE: DeviceModelInfo;
195+
ADD_NEW_DEVICE_MODEL: DeviceModelId;
196196
SET_DEEPLINK_URL: string | null | undefined;
197197
SET_FIRST_TIME_LEND: never;
198198
SET_SWAP_SELECTABLE_CURRENCIES: string[];
@@ -310,10 +310,11 @@ const handlers: SettingsHandlers = {
310310
: undefined,
311311
}),
312312

313-
ADD_SEEN_DEVICE: (state, { payload }) => ({
313+
ADD_NEW_DEVICE_MODEL: (state, { payload }) => ({
314314
...state,
315-
seenDevices: Array.from(new Set(state.seenDevices.concat(payload))),
315+
devicesModelList: [...new Set(state.devicesModelList.concat(payload))],
316316
}),
317+
317318
SET_DEEPLINK_URL: (state, { payload: deepLinkUrl }) => ({
318319
...state,
319320
deepLinkUrl,
@@ -668,7 +669,8 @@ export const lastSeenDeviceSelector = (state: State): DeviceModelInfo | null | u
668669
}
669670
return state.settings.lastSeenDevice;
670671
};
671-
export const seenDevicesSelector = (state: State): DeviceModelInfo[] => state.settings.seenDevices;
672+
export const devicesModelListSelector = (state: State): DeviceModelId[] =>
673+
state.settings.devicesModelList;
672674
export const latestFirmwareSelector = (state: State) => state.settings.latestFirmware;
673675
export const swapHasAcceptedIPSharingSelector = (state: State) =>
674676
state.settings.swap.hasAcceptedIPSharing;

apps/ledger-live-desktop/src/renderer/screens/manager/AppsList/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import AppDepsInstallModal from "./AppDepsInstallModal";
2020
import AppDepsUnInstallModal from "./AppDepsUnInstallModal";
2121
import ErrorModal from "~/renderer/modals/ErrorModal/index";
2222
import {
23-
addNewDevice,
23+
addNewDeviceModel,
2424
clearLastSeenCustomImage,
2525
setHasInstalledApps,
2626
setLastSeenDeviceInfo,
@@ -149,7 +149,7 @@ const AppsList = ({
149149
latestFirmware: firmware,
150150
}),
151151
);
152-
reduxDispatch(addNewDevice({ seenDevice: lastSeenDevice }));
152+
reduxDispatch(addNewDeviceModel({ deviceModelId: lastSeenDevice.modelId }));
153153
}, [device, state.installed, deviceInfo, reduxDispatch, firmware]);
154154

155155
useEffect(() => {

0 commit comments

Comments
 (0)