From 4b2d9ef1d158f66398cbc59041f6afea6ba23792 Mon Sep 17 00:00:00 2001 From: MateuszMudita <165778944+MateuszMudita@users.noreply.github.com> Date: Mon, 16 Sep 2024 13:32:31 +0200 Subject: [PATCH] Release v2.4.0 - to stage (#2062) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Daniel Karski Co-authored-by: MichaƂ Kurczewski --- apps/mudita-center/package-lock.json | 4 +-- apps/mudita-center/package.json | 2 +- .../core/hooks/use-device-connected-effect.ts | 8 ++++-- .../api-device-initialization-modal-flow.tsx | 25 ++++++++++++------- .../lib/file-manager/file-manager.service.ts | 6 ++--- .../lib/hooks/use-locked-device-handler.ts | 6 ++--- .../store/src/lib/selectors/api-error.ts | 5 ++-- .../is-device-locked-error.selector.ts | 10 +++++--- .../store/src/lib/views/reducer.ts | 18 +++++++------ .../lib/predefined/backup/backup-password.tsx | 9 ++++--- package-lock.json | 4 +-- package.json | 1 - 12 files changed, 58 insertions(+), 40 deletions(-) diff --git a/apps/mudita-center/package-lock.json b/apps/mudita-center/package-lock.json index dcbbc9011a..c6474fb501 100644 --- a/apps/mudita-center/package-lock.json +++ b/apps/mudita-center/package-lock.json @@ -1,12 +1,12 @@ { "name": "@mudita/mudita-center-app", - "version": "2.3.1", + "version": "2.4.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@mudita/mudita-center-app", - "version": "2.3.1", + "version": "2.4.0", "license": "GPL-3.0", "dependencies": { "serialport": "10.1.0" diff --git a/apps/mudita-center/package.json b/apps/mudita-center/package.json index 9e187cd233..c7a5e560e6 100644 --- a/apps/mudita-center/package.json +++ b/apps/mudita-center/package.json @@ -1,6 +1,6 @@ { "name": "mudita-center", - "version": "2.3.1", + "version": "2.4.0", "description": "Mudita Center", "main": "./dist/main.js", "productName": "Mudita Center", diff --git a/libs/core/core/hooks/use-device-connected-effect.ts b/libs/core/core/hooks/use-device-connected-effect.ts index aa5a220142..abe348833f 100644 --- a/libs/core/core/hooks/use-device-connected-effect.ts +++ b/libs/core/core/hooks/use-device-connected-effect.ts @@ -23,7 +23,7 @@ import { DeviceBaseProperties, } from "device-protocol/models" import { selectDialogOpenState } from "shared/app-state" -import { Dispatch } from "Core/__deprecated__/renderer/store" +import { Dispatch, ReduxRootState } from "Core/__deprecated__/renderer/store" import { isActiveDeviceProcessingSelector } from "Core/device/selectors/is-active-device-processing.selector" import { setDiscoveryStatus } from "Core/discovery-device/actions/base.action" import { DiscoveryStatus } from "Core/discovery-device/reducers/discovery-device.interface" @@ -44,7 +44,11 @@ export const useDeviceConnectedEffect = () => { const dispatch = useDispatch() const activeDeviceId = useSelector(activeDeviceIdSelector) - const activeApiDeviceLocked = useSelector(isActiveApiDeviceLockedSelector) + const activeApiDeviceLocked = useSelector((state: ReduxRootState) => + activeDeviceId + ? isActiveApiDeviceLockedSelector(state, activeDeviceId) + : false + ) const shouldDiscoverySkipOnConnect = useDiscoverySkipOnConnect() const continueProcess = useContinueProcess() diff --git a/libs/core/device-initialization/components/devices-initialization-modal-flows/api-device-initialization-modal-flow.tsx b/libs/core/device-initialization/components/devices-initialization-modal-flows/api-device-initialization-modal-flow.tsx index 315dfaf021..b684c93e80 100644 --- a/libs/core/device-initialization/components/devices-initialization-modal-flows/api-device-initialization-modal-flow.tsx +++ b/libs/core/device-initialization/components/devices-initialization-modal-flows/api-device-initialization-modal-flow.tsx @@ -21,6 +21,7 @@ import { selectDataMigrationTargetDevice, setDataMigrationSourceDevice, } from "generic-view/store" +import { activeDeviceIdSelector } from "active-device-registry/feature" import { Modal } from "generic-view/ui" import { GenericThemeProvider } from "generic-view/theme" import { ButtonAction, IconType } from "generic-view/utils" @@ -53,18 +54,24 @@ export const APIDeviceInitializationModalFlow: FunctionComponent = () => { const deactivateDeviceAndRedirect = useDeactivateDeviceAndRedirect() const selectDevice = useDataMigrationDeviceSelector() const firstRenderTime = useRef(Date.now()) - const deviceLocked = useSelector((state: ReduxRootState) => { - return selectApiError(state, ApiError.DeviceLocked) - }) const menuElements = useSelector(selectActiveDeviceMenuElements) - const [pathToGoBack] = useFilteredRoutesHistory([ - URL_MAIN.root, - ...Object.values(URL_ONBOARDING), - ...Object.values(URL_DISCOVERY_DEVICE), - ...Object.values(URL_DEVICE_INITIALIZATION), - ], URL_DISCOVERY_DEVICE.availableDeviceListModal) + const [pathToGoBack] = useFilteredRoutesHistory( + [ + URL_MAIN.root, + ...Object.values(URL_ONBOARDING), + ...Object.values(URL_DISCOVERY_DEVICE), + ...Object.values(URL_DEVICE_INITIALIZATION), + ], + URL_DISCOVERY_DEVICE.availableDeviceListModal + ) const dataMigrationSourceDevice = useSelector(selectDataMigrationSourceDevice) const dataMigrationTargetDevice = useSelector(selectDataMigrationTargetDevice) + const activeDeviceId = useSelector(activeDeviceIdSelector) + const deviceLocked = useSelector((state: ReduxRootState) => + activeDeviceId + ? selectApiError(state, activeDeviceId, ApiError.DeviceLocked) + : false + ) const targetPath = useMemo(() => { const firstMenuItemUrl = menuElements?.[0]?.items?.[0]?.button.url diff --git a/libs/device/feature/src/lib/file-manager/file-manager.service.ts b/libs/device/feature/src/lib/file-manager/file-manager.service.ts index e5bdd10852..65e2dd0361 100644 --- a/libs/device/feature/src/lib/file-manager/file-manager.service.ts +++ b/libs/device/feature/src/lib/file-manager/file-manager.service.ts @@ -43,7 +43,7 @@ export class FileManager { try { const file = this.serviceBridge.fileTransfer.getFileByTransferId(transferId) - writeFileSync(filePath, file.chunks.join(), "base64") + writeFileSync(filePath, file.chunks.join(""), "base64") return Result.success(undefined) } catch (e) { @@ -130,8 +130,8 @@ export class FileManager { this.serviceBridge.fileTransfer.getFileByTransferId(transferId) const featureData = password - ? AES.encrypt(transfer.chunks.join(), password).toString() - : transfer.chunks.join() + ? AES.encrypt(transfer.chunks.join(""), password).toString() + : transfer.chunks.join("") return { ...acc, [feature]: featureData } }, diff --git a/libs/generic-view/store/src/lib/hooks/use-locked-device-handler.ts b/libs/generic-view/store/src/lib/hooks/use-locked-device-handler.ts index 7f06e891a4..6991c0ec5d 100644 --- a/libs/generic-view/store/src/lib/hooks/use-locked-device-handler.ts +++ b/libs/generic-view/store/src/lib/hooks/use-locked-device-handler.ts @@ -17,9 +17,9 @@ import { getAPIConfig } from "../get-api-config" export const useLockedDeviceHandler = () => { const dispatch = useDispatch() const deviceId = useSelector(selectActiveApiDeviceId) - const deviceLocked = useSelector((state: ReduxRootState) => { - return selectApiError(state, ApiError.DeviceLocked) - }) + const deviceLocked = useSelector((state: ReduxRootState) => + deviceId ? selectApiError(state, deviceId, ApiError.DeviceLocked) : false + ) const features = useSelector(selectActiveDeviceFeatures) useEffect(() => { diff --git a/libs/generic-view/store/src/lib/selectors/api-error.ts b/libs/generic-view/store/src/lib/selectors/api-error.ts index add9145aa9..2e4e08a8a9 100644 --- a/libs/generic-view/store/src/lib/selectors/api-error.ts +++ b/libs/generic-view/store/src/lib/selectors/api-error.ts @@ -14,6 +14,7 @@ export const selectApiErrors = createSelector( export const selectApiError = createSelector( selectApiErrors, - (state: ReduxRootState, apiError: ApiError) => apiError, - (apiErrors, apiError) => apiErrors[apiError] + (state: ReduxRootState, deviceId: string) => deviceId, + (state: ReduxRootState, deviceId: string, apiError: ApiError) => apiError, + (apiErrors, deviceId, apiError) => apiErrors[deviceId]?.[apiError] ) diff --git a/libs/generic-view/store/src/lib/selectors/is-device-locked-error.selector.ts b/libs/generic-view/store/src/lib/selectors/is-device-locked-error.selector.ts index 8e149df76d..b116cee2f1 100644 --- a/libs/generic-view/store/src/lib/selectors/is-device-locked-error.selector.ts +++ b/libs/generic-view/store/src/lib/selectors/is-device-locked-error.selector.ts @@ -5,11 +5,15 @@ import { createSelector } from "@reduxjs/toolkit" import { ApiError } from "device/models" +import { ReduxRootState } from "Core/__deprecated__/renderer/store" import { selectGenericViewState } from "./select-generic-view-state" export const isDeviceLockedErrorSelector = createSelector( - selectGenericViewState, - (genericState): boolean => { - return genericState.apiErrors[ApiError.DeviceLocked] + [ + selectGenericViewState, + (state: ReduxRootState, deviceId: string) => deviceId, + ], + (genericState, deviceId): boolean => { + return genericState.apiErrors[deviceId]?.[ApiError.DeviceLocked] } ) diff --git a/libs/generic-view/store/src/lib/views/reducer.ts b/libs/generic-view/store/src/lib/views/reducer.ts index 088f648dda..536ebaec03 100644 --- a/libs/generic-view/store/src/lib/views/reducer.ts +++ b/libs/generic-view/store/src/lib/views/reducer.ts @@ -39,7 +39,7 @@ export interface GenericState { lastResponse: unknown lastRefresh?: number devices: Record - apiErrors: Record + apiErrors: Record> } const initialState: GenericState = { @@ -47,9 +47,7 @@ const initialState: GenericState = { views: {}, lastResponse: {}, devices: {}, - apiErrors: { - [ApiError.DeviceLocked]: false, - }, + apiErrors: {}, } export const genericViewsReducer = createReducer(initialState, (builder) => { @@ -99,7 +97,9 @@ export const genericViewsReducer = createReducer(initialState, (builder) => { state.devices[action.payload.deviceId].menuConfig = action.payload.menuConfig state.lastResponse = action.payload - state.apiErrors[ApiError.DeviceLocked] = false + state.apiErrors[action.payload.deviceId] = { + [ApiError.DeviceLocked]: false, + } }) builder.addCase(getMenuConfig.rejected, (state, action) => { const error = action.payload as AppError @@ -107,7 +107,9 @@ export const genericViewsReducer = createReducer(initialState, (builder) => { ? (Number(error.type) as ApiError) : undefined if (apiError && ApiError[apiError]) { - state.apiErrors[apiError] = true + state.apiErrors[action.meta.arg.deviceId] = { + [apiError]: true, + } } if (apiError !== ApiError.DeviceLocked) { @@ -168,7 +170,9 @@ export const genericViewsReducer = createReducer(initialState, (builder) => { state.lastRefresh = action.payload }) builder.addCase(getOutboxData.fulfilled, (state, action) => { - state.apiErrors[ApiError.DeviceLocked] = false + state.apiErrors[action.payload.deviceId] = { + [ApiError.DeviceLocked]: false, + } }) builder.addCase(getGenericConfig.fulfilled, (state, action) => { const { deviceId, feature, view } = action.payload diff --git a/libs/generic-view/ui/src/lib/predefined/backup/backup-password.tsx b/libs/generic-view/ui/src/lib/predefined/backup/backup-password.tsx index 37bf9ea581..f23d4615eb 100644 --- a/libs/generic-view/ui/src/lib/predefined/backup/backup-password.tsx +++ b/libs/generic-view/ui/src/lib/predefined/backup/backup-password.tsx @@ -54,8 +54,8 @@ export const BackupPassword: FunctionComponent = ({ nextAction, }) => { const { watch, formState } = useFormContext() - const password = watch("password") - const passwordRepeat = watch("passwordRepeat") + const password = watch("password") || "" + const passwordRepeat = watch("passwordRepeat") || "" const passwordsMatching = password === passwordRepeat @@ -89,9 +89,10 @@ export const BackupPassword: FunctionComponent = ({ label: intl.formatMessage(messages.passwordRepeatPlaceholder), type: "password", validation: { - validate: (value: string, formValues) => { + validate: (value = "", formValues) => { + const password = formValues.password || "" return ( - value === formValues.password || + value === password || intl.formatMessage(messages.passwordRepeatNotMatchingError) ) }, diff --git a/package-lock.json b/package-lock.json index ec927b1be3..8f6bcf7342 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,10 @@ { "name": "mudita-center", - "version": "2.3.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "mudita-center", - "version": "2.3.0", "license": "GPL-3.0", "dependencies": { "@contentful/rich-text-plain-text-renderer": "^16.2.6", @@ -257,7 +255,7 @@ } }, "apps/mudita-center": { - "version": "2.3.1", + "version": "2.4.0", "license": "GPL-3.0", "dependencies": { "serialport": "10.1.0" diff --git a/package.json b/package.json index 11444a0a16..2680fc2e24 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,6 @@ "name": "mudita-center", "description": "Mudita Center", "productName": "Mudita Center", - "version": "2.3.0", "private": true, "workspaces": { "packages": [