[Glitch] Fix error when collection is null in collection notification
Port 31f89617d80ce65ac9d3a89dca7f66a4485a9074 to glitch-soc Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
parent
20e9618e6d
commit
57ed939d00
@ -27,7 +27,7 @@ const messages = defineMessages({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export function useConfirmRevoke(collection?: ApiCollectionJSON) {
|
export function useConfirmRevoke(collection?: ApiCollectionJSON | null) {
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
const { id, items = [] } = collection ?? {};
|
const { id, items = [] } = collection ?? {};
|
||||||
const ownCollectionItemId = items.find((item) => item.account_id === me)?.id;
|
const ownCollectionItemId = items.find((item) => item.account_id === me)?.id;
|
||||||
|
|||||||
@ -24,9 +24,14 @@ export const NotificationCollection: React.FC<{
|
|||||||
unread: boolean;
|
unread: boolean;
|
||||||
}> = ({ notification, unread }) => {
|
}> = ({ notification, unread }) => {
|
||||||
const { collection, type } = notification;
|
const { collection, type } = notification;
|
||||||
const collectionCreatorAccount = useAccount(collection.account_id);
|
|
||||||
|
const collectionCreatorAccount = useAccount(collection?.account_id);
|
||||||
const confirmRevoke = useConfirmRevoke(collection);
|
const confirmRevoke = useConfirmRevoke(collection);
|
||||||
|
|
||||||
|
if (!collection) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={classNames(
|
className={classNames(
|
||||||
|
|||||||
@ -91,11 +91,11 @@ export interface NotificationGroupAdminReport extends BaseNotification<'admin.re
|
|||||||
|
|
||||||
type Collection = ApiCollectionJSON;
|
type Collection = ApiCollectionJSON;
|
||||||
export interface NotificationGroupAddedToCollection extends BaseNotification<'added_to_collection'> {
|
export interface NotificationGroupAddedToCollection extends BaseNotification<'added_to_collection'> {
|
||||||
collection: Collection;
|
collection: Collection | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface NotificationGroupCollectionUpdate extends BaseNotification<'collection_update'> {
|
export interface NotificationGroupCollectionUpdate extends BaseNotification<'collection_update'> {
|
||||||
collection: Collection;
|
collection: Collection | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type NotificationGroup =
|
export type NotificationGroup =
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user