-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CP-XXX] Implement Refresh Functionality for FilesManager Data (by fe…
…ature key)
- Loading branch information
Showing
15 changed files
with
295 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
libs/device/feature/src/lib/api-features/get-file-manager-data.request.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** | ||
* Copyright (c) Mudita sp. z o.o. All rights reserved. | ||
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md | ||
*/ | ||
|
||
import { ipcRenderer } from "electron-better-ipc" | ||
import { McFileManagerData } from "generic-view/models" | ||
import { APIFeaturesServiceEvents } from "device/models" | ||
import { ResultObject } from "Core/core/builder" | ||
import { DeviceId } from "Core/device/constants/device-id" | ||
|
||
export const getFileManagerDataRequest = ( | ||
deviceId: DeviceId | ||
): Promise<ResultObject<McFileManagerData>> => { | ||
return ipcRenderer.callMain(APIFeaturesServiceEvents.GetFileManagerData, { | ||
deviceId, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
libs/generic-view/store/src/lib/features/get-file-manager-data.actions.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/** | ||
* 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 { DeviceId } from "Core/device/constants/device-id" | ||
import { getFileManagerDataRequest } from "device/feature" | ||
import { generateFileManagerData } from "generic-view/views" | ||
import { selectConfiguredDevice } from "../selectors/select-configured-devices" | ||
import { FeaturesActions } from "./featues-action-keys" | ||
|
||
export const getFileManagerData = createAsyncThunk< | ||
{ | ||
deviceId: DeviceId | ||
data: Record<string, unknown> | ||
}, | ||
{ deviceId: DeviceId }, | ||
{ state: ReduxRootState } | ||
>( | ||
FeaturesActions.GetFileManagerData, | ||
async ({ deviceId }, { rejectWithValue, getState }) => { | ||
const apiConfig = selectConfiguredDevice(getState(), deviceId)?.apiConfig | ||
|
||
const features = selectConfiguredDevice(getState(), deviceId)?.features | ||
const fileManagerConfig = features?.["fileManager"]?.config | ||
|
||
if (apiConfig === undefined || fileManagerConfig === undefined) { | ||
return rejectWithValue("no device") | ||
} | ||
|
||
const response = await getFileManagerDataRequest(deviceId) | ||
|
||
if (response.ok) { | ||
return { | ||
deviceId, | ||
data: generateFileManagerData(response.data, fileManagerConfig), | ||
} | ||
} | ||
return rejectWithValue(response.error) | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.