Skip to content

Commit

Permalink
Merge branch 'develop' into CP-3171
Browse files Browse the repository at this point in the history
  • Loading branch information
robertmudi authored Dec 21, 2024
2 parents 1566829 + 106f4b5 commit 832f695
Show file tree
Hide file tree
Showing 9 changed files with 124 additions and 1 deletion.
40 changes: 40 additions & 0 deletions .github/workflows/e2e-feature-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,46 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: 18.16.1
- name: Find open port for ChromeBrowser on Linux/Mac
if: matrix.os != 'Windows'
id: find-port-unix
run: |
START_PORT=30000
END_PORT=40000
PORT=$START_PORT
RUNNER_OS="${{ matrix.os }}"
while [ $PORT -le $END_PORT ]; do
if [[ "$RUNNER_OS" == "Linux" ]]; then
nc -z 127.0.0.1 $PORT 2>/dev/null || break
elif [[ "$RUNNER_OS" == "macOS" ]]; then
nc -z -w1 127.0.0.1 $PORT 2>/dev/null || break
fi
PORT=$((PORT+1))
done
if [ $PORT -gt $END_PORT ]; then
echo "No available port found in the range $START_PORT-$END_PORT" >&2
exit 1
fi
echo "CHROME_OPEN_PORT=$PORT" >> $GITHUB_ENV
- name: Find open port for ChromeBrowser on Windows
if: matrix.os == 'Windows'
id: find-port-windows
run: |
$startPort = 30000
$endPort = 40000
$port = $startPort
while ($port -le $endPort) {
$isUsed = (Test-NetConnection -ComputerName 127.0.0.1 -Port $port).TcpTestSucceeded
if (-not $isUsed) {
break
}
$port++
}
if ($port -gt $endPort) {
Write-Error "No available port found in the range $startPort-$endPort"
exit 1
}
echo "CHROME_OPEN_PORT=$port" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8
- name: Setup environment variables for Linux
if: matrix.os == 'Linux'
env:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1045,5 +1045,5 @@
"module.recoveryMode.modal.terminalInfo.step3": "3. Enter your computer password when prompted",
"module.recoveryMode.modal.terminalInfo.step4": "4. Repeat your computer password when prompted",
"module.recoveryMode.modal.completed.subtitle": "Recovery process complete",
"module.recoveryMode.modal.completed.description": "Harmony is in transport mode. Press the light button when \"ON\" and \"OFF\" appear on harmony's screen."
"module.recoveryMode.modal.completed.description": "Hold down the light button on Harmony to turn it on when prompted."
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { z } from "zod"

export const entitiesMetadataValidator = z.object({
totalEntities: z.number().nonnegative(),
uniqueKey: z.string().optional(),
})

export type EntitiesMetadata = z.infer<typeof entitiesMetadataValidator>
1 change: 1 addition & 0 deletions libs/generic-view/store/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export * from "./lib/entities/get-entities-metadata.action"
export * from "./lib/entities/delete-entities-data.action"
export * from "./lib/entities/create-entity-data.action"
export * from "./lib/entities/update-entity-data.action"
export * from "./lib/entities/refresh-entities-if-metadata-changed.action"

export * from "./lib/data-migration/reducer"
export * from "./lib/data-migration/actions"
Expand Down
1 change: 1 addition & 0 deletions libs/generic-view/store/src/lib/action-names.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,5 @@ export enum ActionName {
DeleteEntityData = "entities/delete-entity-data",
CreateEntityData = "entities/create-entity-data",
UpdateEntityData = "entities/update-entity-data",
RefreshEntitiesIfMetadataChanged = "entities/refresh-entities-if-metadata-changed",
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { selectActiveApiDeviceId } from "../selectors/select-active-api-device-i
import { setRestoreProcessFileStatus, setRestoreProcessStatus } from "./actions"
import { BackupProcessFileStatus, RestoreProcessStatus } from "./backup.types"
import { delay } from "shared/utils"
import { refreshEntitiesIfMetadataChanged } from "../entities/refresh-entities-if-metadata-changed.action"

export const restoreBackup = createAsyncThunk<
undefined,
Expand Down Expand Up @@ -221,6 +222,14 @@ export const restoreBackup = createAsyncThunk<
return rejectWithValue(undefined)
}
dispatch(setRestoreProcessStatus({ status: RestoreProcessStatus.Done }))

await dispatch(
refreshEntitiesIfMetadataChanged({
deviceId: deviceId,
entitiesType: "contacts",
})
)

return undefined
}
)
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import { removeDirectory } from "system-utils/feature"
import { DataMigrationStatus } from "./reducer"
import { clearMigrationData } from "./clear-migration-data"
import { pureToUnifiedMessage } from "./data-migration-mappers/pure-to-unified-message"
import { refreshEntitiesIfMetadataChanged } from "../entities/refresh-entities-if-metadata-changed.action"
import { selectActiveApiDeviceId } from "../selectors"

export const transferMigrationData = createAsyncThunk<
void,
Expand Down Expand Up @@ -56,6 +58,12 @@ export const transferMigrationData = createAsyncThunk<
return rejectWithValue(undefined)
}

const deviceId = selectActiveApiDeviceId(getState())

if (!deviceId) {
return handleError("Device not found")
}

const sourceDeviceId = dataMigration.sourceDevice
if (!sourceDeviceId) {
return handleError("Source device not selected")
Expand Down Expand Up @@ -173,6 +181,15 @@ export const transferMigrationData = createAsyncThunk<

await delay()

if (domainsData.some((obj) => obj.domain === "contacts-v1")) {
await dispatch(
refreshEntitiesIfMetadataChanged({
deviceId: deviceId,
entitiesType: "contacts",
})
)
}

dispatch(setDataMigrationStatus(DataMigrationStatus.Completed))

return
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/**
* Copyright (c) Mudita sp. z o.o. All rights reserved.
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/

import { createAsyncThunk } from "@reduxjs/toolkit"
import { ReduxRootState } from "Core/__deprecated__/renderer/store"
import { ActionName } from "../action-names"
import { getEntitiesMetadataAction } from "./get-entities-metadata.action"
import { selectEntitiesMetadata } from "../selectors"
import { getEntitiesDataAction } from "./get-entities-data.action"
import { EntitiesMetadata } from "Libs/device/models/src"

export const refreshEntitiesIfMetadataChanged = createAsyncThunk<
void,
{ deviceId: string; entitiesType: string },
{ state: ReduxRootState }
>(
ActionName.RefreshEntitiesIfMetadataChanged,
async (
{ deviceId, entitiesType },
{ dispatch, getState, rejectWithValue }
) => {
if (!deviceId) {
return rejectWithValue(undefined)
}

const currentMetadata = selectEntitiesMetadata(getState(), {
deviceId,
entitiesType,
})

const metadata = await dispatch(
getEntitiesMetadataAction({ deviceId, entitiesType })
)

if (
currentMetadata?.uniqueKey !==
(metadata.payload as EntitiesMetadata)?.uniqueKey
) {
dispatch(getEntitiesDataAction({ deviceId, entitiesType }))
}

return
}
)
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { sendFile } from "../file-transfer/send-file.action"
import { selectActiveApiDeviceId } from "../selectors"
import { setImportProcessFileStatus, setImportProcessStatus } from "./actions"
import { delay } from "shared/utils"
import { refreshEntitiesIfMetadataChanged } from "../entities/refresh-entities-if-metadata-changed.action"

export const startImportToDevice = createAsyncThunk<
undefined,
Expand Down Expand Up @@ -254,6 +255,13 @@ export const startImportToDevice = createAsyncThunk<
return rejectWithValue(undefined)
}

await dispatch(
refreshEntitiesIfMetadataChanged({
deviceId: deviceId,
entitiesType: "contacts",
})
)

return undefined
}
)

0 comments on commit 832f695

Please sign in to comment.