Skip to content

Commit

Permalink
Release v2.4.0 - to stage (#2062)
Browse files Browse the repository at this point in the history
Co-authored-by: Daniel Karski <[email protected]>
Co-authored-by: Michał Kurczewski <[email protected]>
  • Loading branch information
3 people authored Sep 16, 2024
1 parent 9ea9732 commit 4b2d9ef
Show file tree
Hide file tree
Showing 12 changed files with 58 additions and 40 deletions.
4 changes: 2 additions & 2 deletions apps/mudita-center/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion apps/mudita-center/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
8 changes: 6 additions & 2 deletions libs/core/core/hooks/use-device-connected-effect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -44,7 +44,11 @@ export const useDeviceConnectedEffect = () => {
const dispatch = useDispatch<Dispatch>()

const activeDeviceId = useSelector(activeDeviceIdSelector)
const activeApiDeviceLocked = useSelector(isActiveApiDeviceLockedSelector)
const activeApiDeviceLocked = useSelector((state: ReduxRootState) =>
activeDeviceId
? isActiveApiDeviceLockedSelector(state, activeDeviceId)
: false
)

const shouldDiscoverySkipOnConnect = useDiscoverySkipOnConnect()
const continueProcess = useContinueProcess()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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 }
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ import { getAPIConfig } from "../get-api-config"
export const useLockedDeviceHandler = () => {
const dispatch = useDispatch<Dispatch>()
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(() => {
Expand Down
5 changes: 3 additions & 2 deletions libs/generic-view/store/src/lib/selectors/api-error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]
)
Original file line number Diff line number Diff line change
Expand Up @@ -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]
}
)
18 changes: 11 additions & 7 deletions libs/generic-view/store/src/lib/views/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,15 @@ export interface GenericState {
lastResponse: unknown
lastRefresh?: number
devices: Record<string, Device>
apiErrors: Record<ApiError, boolean>
apiErrors: Record<string, Record<ApiError, boolean>>
}

const initialState: GenericState = {
menu: undefined,
views: {},
lastResponse: {},
devices: {},
apiErrors: {
[ApiError.DeviceLocked]: false,
},
apiErrors: {},
}

export const genericViewsReducer = createReducer(initialState, (builder) => {
Expand Down Expand Up @@ -99,15 +97,19 @@ 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
const apiError = !isNaN(Number(error.type))
? (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) {
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ export const BackupPassword: FunctionComponent<Props> = ({
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

Expand Down Expand Up @@ -89,9 +89,10 @@ export const BackupPassword: FunctionComponent<Props> = ({
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)
)
},
Expand Down
4 changes: 1 addition & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"name": "mudita-center",
"description": "Mudita Center",
"productName": "Mudita Center",
"version": "2.3.0",
"private": true,
"workspaces": {
"packages": [
Expand Down

0 comments on commit 4b2d9ef

Please sign in to comment.