Skip to content

Conversation

@joseivanlopez
Copy link
Contributor

See #2235.

…oject#2235)

## Problem

The storage page shows an empty state (no devices found) after
activating/deactivating devices.

Steps to reproduce: 

* Go to iSCSI page and activate devices.
* Go back to storage.
* The storage page shows "No devices found" instead of the configured
devices and result.

## Solution

Source of the problem: the query for getting the available devices
requires the result of the query for getting all the devices, but it is
not refreshed when there are changes in the list of devices.

For solving it, the `useAvailableDevices` hook uses *useMemo* which
refreshes the list of available devices if any of the source data
changes (either *devices* or the list of *usable Devices*).

See
https://tkdodo.eu/blog/react-query-data-transformations#2-in-the-render-function:
"Especially if you have additional logic in your custom hook to combine
with your data transformation, this is a good option."

## Testing

* Tested manually
@joseivanlopez joseivanlopez merged commit 9119271 into agama-project:master Apr 1, 2025
1 check passed
@imobachgs imobachgs mentioned this pull request Apr 22, 2025
imobachgs added a commit that referenced this pull request Apr 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants