Skip to content

Commit

Permalink
change querykeys
Browse files Browse the repository at this point in the history
  • Loading branch information
Dnouv committed Jan 11, 2023
1 parent afc85a0 commit 31b3959
Show file tree
Hide file tree
Showing 18 changed files with 22 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ import React from 'react';
import AccordionLoading from '../../../AccordionLoading';
import AppReleasesItem from './AppReleasesItem';

// TODO: replace useEndpointData
const AppReleases = ({ id }: { id: App['id'] }): ReactElement => {
const getVersions = useEndpoint('GET', `/apps/${id}/versions`);
const getVersions = useEndpoint('GET', '/apps/:id/versions', { id });

const { data, isLoading, isFetched } = useQuery(['versions'], async () => {
const { data, isLoading, isFetched } = useQuery(['apps', id, 'versions'], async () => {
const versions = await getVersions();
return versions;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const EditCustomEmojiWithData: FC<EditCustomEmojiWithDataProps> = ({ _id, onChan

const getEmojis = useEndpoint('GET', '/v1/emoji-custom.list');

const { data, isLoading, error, refetch } = useQuery(['emojis.list', query], async () => {
const { data, isLoading, error, refetch } = useQuery(['custom-emojis', query], async () => {
const emoji = await getEmojis(query);
return emoji;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const CustomSoundsRoute = (): ReactElement => {

const getSounds = useEndpoint('GET', '/v1/custom-sounds.list');

const { data, refetch, ...result } = useQuery(['custom-sounds.list', query], async () => {
const { data, refetch, ...result } = useQuery(['custom-sounds', query], async () => {
const sound = await getSounds(query);
return sound;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function EditCustomSound({ _id, onChange, ...props }: EditCustomSoundProps): Rea

const getSounds = useEndpoint('GET', '/v1/custom-sounds.list');

const { data, isLoading, error, refetch } = useQuery(['custom-sounds.list', query], async () => {
const { data, isLoading, error, refetch } = useQuery(['custom-sounds', query], async () => {
const sound = await getSounds(query);
return sound;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const CustomUserStatusFormWithData = ({ _id, onReload, onClose }: CustomUserStat

const getCustomUserStatus = useEndpoint('GET', '/v1/custom-user-status.list');

const { data, isLoading, error, refetch } = useQuery(['custom-user-status.list', query], async () => {
const { data, isLoading, error, refetch } = useQuery(['custom-user-statuses', query], async () => {
const customUserStatus = await getCustomUserStatus(query);
return customUserStatus;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const CustomUserStatus = ({ reload, onClick }: CustomUserStatusProps): ReactElem

const getCustomUserStatus = useEndpoint('GET', '/v1/custom-user-status.list');

const { data, isLoading, error, refetch, isFetched } = useQuery(['custom-user-status', query], async () => {
const { data, isLoading, error, refetch, isFetched } = useQuery(['custom-user-statuses', query], async () => {
const userStatus = await getCustomUserStatus(query);
return userStatus;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function IntegrationsTable({ type }) {

const getIntegrations = useEndpoint('GET', '/v1/integrations.list');

const { data } = useQuery(['integrations.list', query], async () => {
const { data } = useQuery(['integrations', query], async () => {
const integrations = await getIntegrations(query);
return integrations;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function EditIncomingWebhookWithData({ integrationId, ...props }) {

const getIntegrations = useEndpoint('GET', '/v1/integrations.get');

const { data, isLoading, error, refetch } = useQuery(['integrations.get', params], async () => {
const { data, isLoading, error, refetch } = useQuery(['integrations', params], async () => {
const integrations = await getIntegrations(params);
return integrations;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function EditOutgoingWebhookWithData({ integrationId, ...props }) {

const getIntegrations = useEndpoint('GET', '/v1/integrations.get');

const { data, isLoading, error, refetch } = useQuery(['integrations.get', params], async () => {
const { data, isLoading, error, refetch } = useQuery(['integrations', params], async () => {
const integrations = await getIntegrations(params);
return integrations;
});
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/client/views/admin/invites/InvitesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const InvitesPage = (): ReactElement => {

const getInvites = useEndpoint('GET', '/v1/listInvites');

const { data, isLoading, refetch, isFetched } = useQuery(['listInvites'], async () => {
const { data, isLoading, refetch, isFetched } = useQuery(['invites'], async () => {
const invites = await getInvites();
return invites;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const OAuthAppsTable = (): ReactElement => {
const uid = { uid: useUserId() || '' };

const getOauthApps = useEndpoint('GET', '/v1/oauth-apps.list');
const { data } = useQuery(['oauth-apps'], async () => {
const { data } = useQuery(['oauth-apps', { uid }], async () => {
const oauthApps = await getOauthApps(uid);
return oauthApps;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const UsersInRoleTableWithData = ({

const getUsersInRole = useEndpoint('GET', '/v1/roles.getUsersInRole');

const { refetch, ...result } = useQuery(['usersInRole', query], async () => {
const { refetch, ...result } = useQuery(['roles', roleId, 'users', query], async () => {
const users = await getUsersInRole(query);
return users;
});
Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/client/views/admin/rooms/EditRoomWithData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import { Box, Skeleton } from '@rocket.chat/fuselage';
import { useEndpoint } from '@rocket.chat/ui-contexts';
import { useQuery } from '@tanstack/react-query';
import type { FC } from 'react';
import React, { useMemo } from 'react';
import React from 'react';

import EditRoom from './EditRoom';

const EditRoomWithData: FC<{ rid?: string; onReload: () => void }> = ({ rid, onReload }) => {
const getAdminRooms = useEndpoint('GET', '/v1/rooms.adminRooms.getRoom');

const { data, isLoading, error, refetch, isError } = useQuery(['rooms', useMemo(() => ({ rid }), [rid])], async () => {
const { data, isLoading, error, refetch, isError } = useQuery(['rooms', rid, 'admin'], async () => {
const rooms = await getAdminRooms({ rid });
return rooms;
});
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/client/views/admin/rooms/RoomsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ const RoomsTable = ({ reload }: { reload: MutableRefObject<() => void> }): React

const getAdminRooms = useEndpoint('GET', '/v1/rooms.adminRooms');

const endpointData = useQuery(['adminRooms', query], async () => {
const endpointData = useQuery(['rooms', query, 'admin'], async () => {
const adminRooms = await getAdminRooms(params);
return adminRooms;
});
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/client/views/admin/users/AddUser.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const AddUser = ({ onReload, ...props }) => {

const getRoleData = useEndpoint('GET', '/v1/roles.list');

const { data } = useQuery(['roles.list', ''], async () => {
const { data } = useQuery(['roles'], async () => {
const roles = await getRoleData();
return roles;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const AdminUserInfoWithData = ({ uid, onReload }: AdminUserInfoWithDataProps): R

const query = useMemo(() => ({ userId: uid }), [uid]);

const { data, isLoading, error, refetch } = useQuery(['users.info', query], async () => {
const { data, isLoading, error, refetch } = useQuery(['users', query, 'admin'], async () => {
const usersInfo = await getUsersInfo(query);
return usersInfo;
});
Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/client/views/admin/users/EditUserWithData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const EditUserWithData = ({ uid, onReload, ...props }: EditUserWithDataProps): R
data: roleData,
isLoading: roleState,
error: roleError,
} = useQuery(['roles.list'], async () => {
} = useQuery(['roles'], async () => {
const roles = await getRoles();
return roles;
});
Expand All @@ -36,7 +36,7 @@ const EditUserWithData = ({ uid, onReload, ...props }: EditUserWithDataProps): R
data,
isLoading: state,
error,
} = useQuery(['users.info', query], async () => {
} = useQuery(['users', query, 'admin'], async () => {
const usersInfo = await getUsersInfo(query);
return usersInfo;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const UsersTable = ({ reload }: UsersTableProps): ReactElement | null => {
);

const getUsers = useEndpoint('GET', '/v1/users.list');
const { data, isLoading, error, isSuccess, refetch } = useQuery(['users.list', query], async () => {
const { data, isLoading, error, isSuccess, refetch } = useQuery(['users', query], async () => {
const users = await getUsers(query);
return users;
});
Expand Down

0 comments on commit 31b3959

Please sign in to comment.