Skip to content

Commit 32b6f89

Browse files
authored
Merge pull request #405
refactor(renovate): Upgrade ReactQuery to v5 * refactor(renovate): upgrade react query to v5 * refactor(renovate): refactor queries and mutations * fix(renovate): fix dev tool * chore(renovate): add eslint for react-query * fix(renovate): fix react-query keys (eslint) * fix(renovate): update pnpm for node v20 * chore(19269): linting and code improvement
1 parent 6ef64ec commit 32b6f89

File tree

55 files changed

+268
-230
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+268
-230
lines changed

.github/actions/setup_node/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ inputs:
1111
runs:
1212
using: "composite"
1313
steps:
14-
- uses: pnpm/action-setup@v2
14+
- uses: pnpm/action-setup@v3
1515
name: Install pnpm
1616
id: pnpm-install
1717
with:

hivemq-edge/src/frontend/.eslintrc.cjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ module.exports = {
66
'plugin:react/recommended',
77
'plugin:react-hooks/recommended',
88
'plugin:cypress/recommended',
9+
'plugin:@tanstack/eslint-plugin-query/recommended',
910
],
1011
parser: '@typescript-eslint/parser',
1112
parserOptions: { ecmaVersion: 'latest', sourceType: 'module' },

hivemq-edge/src/frontend/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@
4444
"@rjsf/core": "^5.15.1",
4545
"@rjsf/utils": "^5.15.1",
4646
"@rjsf/validator-ajv8": "^5.15.1",
47-
"@tanstack/react-query": "^4.29.7",
48-
"@tanstack/react-query-devtools": "^4.29.7",
47+
"@tanstack/react-query": "^5.32.1",
48+
"@tanstack/react-query-devtools": "^5.32.1",
4949
"@tanstack/react-table": "^8.9.3",
5050
"@tiptap/extension-document": "^2.2.4",
5151
"@tiptap/extension-mention": "^2.2.4",
@@ -89,6 +89,7 @@
8989
"@chakra-ui/cli": "^2.4.1",
9090
"@percy/cli": "^1.24.2",
9191
"@percy/cypress": "^3.1.2",
92+
"@tanstack/eslint-plugin-query": "^5.32.1",
9293
"@testing-library/jest-dom": "^5.16.5",
9394
"@testing-library/react": "^14.0.0",
9495
"@types/jest": "^29.5.1",

hivemq-edge/src/frontend/pnpm-lock.yaml

Lines changed: 116 additions & 56 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

hivemq-edge/src/frontend/src/api/hooks/useConnection/useGetAdaptersStatus.tsx

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,10 @@ import { QUERY_KEYS } from '@/api/utils.ts'
66
export const useGetAdaptersStatus = () => {
77
const appClient = useHttpClient()
88

9-
return useQuery(
10-
[QUERY_KEYS.ADAPTERS, QUERY_KEYS.CONNECTION_STATUS],
11-
async () => {
12-
const item = await appClient.protocolAdapters.getAdaptersStatus()
13-
return item
14-
},
15-
{
16-
retry: 0,
17-
refetchInterval: () => {
18-
// return data ? 4 * 1000 : Math.max(Math.min(query.state.errorUpdateCount, 5 * 60), 4) * 1000
19-
return config.httpClient.pollingRefetchInterval
20-
},
21-
}
22-
)
9+
return useQuery({
10+
queryKey: [QUERY_KEYS.ADAPTERS, QUERY_KEYS.CONNECTION_STATUS],
11+
queryFn: () => appClient.protocolAdapters.getAdaptersStatus(),
12+
retry: 0,
13+
refetchInterval: config.httpClient.pollingRefetchInterval,
14+
})
2315
}

hivemq-edge/src/frontend/src/api/hooks/useConnection/useGetBridgesStatus.tsx

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,10 @@ import { QUERY_KEYS } from '@/api/utils.ts'
66
export const useGetBridgesStatus = () => {
77
const appClient = useHttpClient()
88

9-
return useQuery(
10-
[QUERY_KEYS.BRIDGES, QUERY_KEYS.CONNECTION_STATUS],
11-
async () => {
12-
const item = await appClient.bridges.getBridgesStatus()
13-
return item
14-
},
15-
{
16-
retry: 0,
17-
refetchInterval: () => {
18-
// return data ? 4 * 1000 : Math.max(Math.min(query.state.errorUpdateCount, 5 * 60), 4) * 1000
19-
return config.httpClient.pollingRefetchInterval
20-
},
21-
}
22-
)
9+
return useQuery({
10+
queryKey: [QUERY_KEYS.BRIDGES, QUERY_KEYS.CONNECTION_STATUS],
11+
queryFn: () => appClient.bridges.getBridgesStatus(),
12+
retry: 0,
13+
refetchInterval: config.httpClient.pollingRefetchInterval,
14+
})
2315
}

hivemq-edge/src/frontend/src/api/hooks/useEvents/useGetEvents.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import { QUERY_KEYS } from '@/api/utils.ts'
66
export const useGetEvents = () => {
77
const appClient = useHttpClient()
88

9-
return useQuery<EventList, ApiError>([QUERY_KEYS.EVENTS], async () => {
10-
return await appClient.events.getEvents()
9+
return useQuery<EventList, ApiError>({
10+
queryKey: [QUERY_KEYS.EVENTS],
11+
queryFn: () => appClient.events.getEvents(),
1112
})
1213
}

0 commit comments

Comments
 (0)