Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: system throws GUI Application error while enabling, disabling and uninstalling an app. #34887

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/giant-bottles-impress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@rocket.chat/meteor": patch
"@rocket.chat/core-typings": patch
---

Fixes an issue where the system would throw the error: 'GUI Application error' while uninstalling an app(when on the requests tab).
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const AppRequests = ({ id, isAdminUser }: { id: App['id']; isAdminUser: boolean
const [limit, setLimit] = useState<itemsPerPage>(25);
const [offset, setOffset] = useState<number>(0);

const paginatedAppRequests = useAppRequests(id, limit, offset);
const { isSuccess, data: paginatedAppRequests, isLoading } = useAppRequests(id, limit, offset);
const { t } = useTranslation();

const onSetItemsPerPage = (itemsPerPageOption: SetStateAction<itemsPerPage>) => setLimit(itemsPerPageOption);
Expand All @@ -35,8 +35,10 @@ const AppRequests = ({ id, isAdminUser }: { id: App['id']; isAdminUser: boolean

useEffect(() => {
return () => {
if (isAdminUser && paginatedAppRequests.isSuccess) {
const unseenRequests = paginatedAppRequests.data.data.filter(({ seen }) => !seen).map(({ id }) => id);
if (isAdminUser && isSuccess) {
// Marketplace returns data = null if the app was removed, so we need to be sure that the thing
// we are filtering & mapping is an array
const unseenRequests = (paginatedAppRequests.data || []).filter(({ seen }) => !seen).map(({ id }) => id);

if (unseenRequests.length) {
markAppRequestsAsSeen.mutate(unseenRequests, {
Expand All @@ -49,9 +51,9 @@ const AppRequests = ({ id, isAdminUser }: { id: App['id']; isAdminUser: boolean
}
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isAdminUser, paginatedAppRequests.isSuccess, paginatedAppRequests?.data, reloadApps]);
}, [isAdminUser, isSuccess, paginatedAppRequests?.data, reloadApps]);

if (paginatedAppRequests.isLoading) {
if (isLoading) {
return (
<Box w='full' maxWidth='x608' marginInline='auto' pbs={36}>
<AppRequestsLoading />
Expand All @@ -62,8 +64,8 @@ const AppRequests = ({ id, isAdminUser }: { id: App['id']; isAdminUser: boolean
return (
<Box h='full' display='flex' flexDirection='column'>
<Box w='full' maxWidth='x608' marginInline='auto' pbs={36} flexGrow='1'>
{paginatedAppRequests.isSuccess && paginatedAppRequests.data.data?.length ? (
paginatedAppRequests.data.data.map((request) => (
{isSuccess && paginatedAppRequests.data?.length ? (
paginatedAppRequests.data.map((request) => (
<AppRequestItem
key={request.id}
seen={request.seen}
Expand All @@ -80,12 +82,12 @@ const AppRequests = ({ id, isAdminUser }: { id: App['id']; isAdminUser: boolean
</States>
)}
</Box>
{paginatedAppRequests.isSuccess && paginatedAppRequests.data.data?.length && (
{isSuccess && paginatedAppRequests.data?.length && (
<Pagination
divider
count={paginatedAppRequests.data.meta.total}
itemsPerPage={paginatedAppRequests.data.meta.limit}
current={paginatedAppRequests.data.meta.offset}
count={paginatedAppRequests.meta.total}
itemsPerPage={paginatedAppRequests.meta.limit}
current={paginatedAppRequests.meta.offset}
onSetItemsPerPage={onSetItemsPerPage}
onSetCurrent={onSetCurrent}
/>
Expand Down
2 changes: 1 addition & 1 deletion packages/core-typings/src/AppRequests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export type Meta = {
};

export type PaginatedAppRequests = {
data: AppRequest[];
data: AppRequest[] | null;
meta: Meta;
};

Expand Down
Loading