Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(LLD): Update modelListId with unique device type #3766

Merged
merged 2 commits into from
Jun 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .changeset/chilled-timers-remember.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
"ledger-live-desktop": patch
---

LLD - Add modelIdList user property and event property
LLD - Add modelIdList user property and event property. The list will be: [ "nanoX", "stax", "nanoS"]
6 changes: 3 additions & 3 deletions apps/ledger-live-desktop/src/renderer/actions/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,9 @@ export const setLastSeenDevice = ({ deviceInfo }: { deviceInfo: DeviceInfo }) =>
},
});

export const addNewDevice = ({ seenDevice }: { seenDevice: DeviceModelInfo }) => ({
type: "ADD_SEEN_DEVICE",
payload: seenDevice,
export const addNewDeviceModel = ({ deviceModelId }: { deviceModelId: DeviceModelId }) => ({
type: "ADD_NEW_DEVICE_MODEL",
payload: deviceModelId,
});
export const setDeepLinkUrl = (url?: string | null) => ({
type: "SET_DEEPLINK_URL",
Expand Down
6 changes: 3 additions & 3 deletions apps/ledger-live-desktop/src/renderer/analytics/segment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
lastSeenDeviceSelector,
localeSelector,
languageSelector,
seenDevicesSelector,
devicesModelListSelector,
} from "~/renderer/reducers/settings";
import { State } from "~/renderer/reducers";
import { AccountLike, idsToLanguage } from "@ledgerhq/types-live";
Expand Down Expand Up @@ -51,7 +51,7 @@ const extraProperties = (store: ReduxStore) => {
const region = (localeSelector(state).split("-")[1] || "").toUpperCase() || null;
const systemLocale = getParsedSystemLocale();
const device = lastSeenDeviceSelector(state);
const devices = seenDevicesSelector(state);
const devices = devicesModelListSelector(state);
const accounts = accountsSelector(state);
const deviceInfo = device
? {
Expand Down Expand Up @@ -100,7 +100,7 @@ const extraProperties = (store: ReduxStore) => {
blockchainsWithNftsOwned,
hasGenesisPass,
hasInfinityPass,
modelIdList: devices.map(d => d.modelId),
modelIdList: devices,
...deviceInfo,
};
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { getCurrentDevice } from "~/renderer/reducers/devices";
import {
setPreferredDeviceModel,
setLastSeenDeviceInfo,
addNewDevice,
addNewDeviceModel,
} from "~/renderer/actions/settings";
import { preferredDeviceModelSelector } from "~/renderer/reducers/settings";
import { DeviceModelId } from "@ledgerhq/devices";
Expand Down Expand Up @@ -245,7 +245,7 @@ export const DeviceActionDefaultRendering = <R, H extends States, P>({
apps: [],
};
dispatch(setLastSeenDeviceInfo({ lastSeenDevice, latestFirmware }));
dispatch(addNewDevice({ seenDevice: lastSeenDevice }));
dispatch(addNewDeviceModel({ deviceModelId: lastSeenDevice.modelId }));
}
}, [dispatch, device, deviceInfo, latestFirmware]);

Expand Down
14 changes: 8 additions & 6 deletions apps/ledger-live-desktop/src/renderer/reducers/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export type SettingsState = {
preferredDeviceModel: DeviceModelId;
hasInstalledApps: boolean;
lastSeenDevice: DeviceModelInfo | undefined | null;
seenDevices: DeviceModelInfo[];
devicesModelList: DeviceModelId[];
latestFirmware: FirmwareUpdateContext | null;
language: string | undefined | null;
theme: string | undefined | null;
Expand Down Expand Up @@ -150,7 +150,7 @@ const INITIAL_STATE: SettingsState = {
hasInstalledApps: true,
carouselVisibility: 0,
lastSeenDevice: null,
seenDevices: [],
devicesModelList: [],
lastSeenCustomImage: {
size: 0,
hash: "",
Expand Down Expand Up @@ -203,7 +203,7 @@ type HandlersPayloads = {
latestFirmware: FirmwareUpdateContext;
};
LAST_SEEN_DEVICE: DeviceModelInfo;
ADD_SEEN_DEVICE: DeviceModelInfo;
ADD_NEW_DEVICE_MODEL: DeviceModelId;
SET_DEEPLINK_URL: string | null | undefined;
SET_FIRST_TIME_LEND: never;
SET_SWAP_SELECTABLE_CURRENCIES: string[];
Expand Down Expand Up @@ -322,10 +322,11 @@ const handlers: SettingsHandlers = {
: undefined,
}),

ADD_SEEN_DEVICE: (state, { payload }) => ({
ADD_NEW_DEVICE_MODEL: (state, { payload }) => ({
...state,
seenDevices: Array.from(new Set(state.seenDevices.concat(payload))),
devicesModelList: [...new Set(state.devicesModelList.concat(payload))],
}),

SET_DEEPLINK_URL: (state, { payload: deepLinkUrl }) => ({
...state,
deepLinkUrl,
Expand Down Expand Up @@ -684,7 +685,8 @@ export const lastSeenDeviceSelector = (state: State): DeviceModelInfo | null | u
}
return state.settings.lastSeenDevice;
};
export const seenDevicesSelector = (state: State): DeviceModelInfo[] => state.settings.seenDevices;
export const devicesModelListSelector = (state: State): DeviceModelId[] =>
state.settings.devicesModelList;
export const latestFirmwareSelector = (state: State) => state.settings.latestFirmware;
export const swapHasAcceptedIPSharingSelector = (state: State) =>
state.settings.swap.hasAcceptedIPSharing;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import AppDepsInstallModal from "./AppDepsInstallModal";
import AppDepsUnInstallModal from "./AppDepsUnInstallModal";
import ErrorModal from "~/renderer/modals/ErrorModal/index";
import {
addNewDevice,
addNewDeviceModel,
clearLastSeenCustomImage,
setHasInstalledApps,
setLastSeenDeviceInfo,
Expand Down Expand Up @@ -149,7 +149,7 @@ const AppsList = ({
latestFirmware: firmware,
}),
);
reduxDispatch(addNewDevice({ seenDevice: lastSeenDevice }));
reduxDispatch(addNewDeviceModel({ deviceModelId: lastSeenDevice.modelId }));
}, [device, state.installed, deviceInfo, reduxDispatch, firmware]);

useEffect(() => {
Expand Down