Skip to content

Commit

Permalink
Refetch moderation count query on Moderated message
Browse files Browse the repository at this point in the history
  • Loading branch information
Anahkiasen committed Sep 20, 2023
1 parent 171d1a8 commit b5815eb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/hooks/useHandleWindowMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const WindowMessageTypes = {
URL_UNKNOWN: 'URL_UNKNOWN',
JOB_ADDED: 'JOB_ADDED',
HTTP_ERROR_CODE: 'HTTP_ERROR_CODE',
OFFER_MODERATED: 'OFFER_MODERATED',
};

const useHandleWindowMessage = (eventsMap = {}) => {
Expand Down
10 changes: 10 additions & 0 deletions src/layouts/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ import {
} from '@/hooks/api/user';
import { useCookiesWithOptions } from '@/hooks/useCookiesWithOptions';
import { FeatureFlags, useFeatureFlag } from '@/hooks/useFeatureFlag';
import {
useHandleWindowMessage,
WindowMessageTypes,
} from '@/hooks/useHandleWindowMessage';
import { useLocalStorage } from '@/hooks/useLocalStorage';
import { useMatchBreakpoint } from '@/hooks/useMatchBreakpoint';
import {
Expand Down Expand Up @@ -317,6 +321,7 @@ const BetaVersionToggle = ({
const Sidebar = () => {
const { t, i18n } = useTranslation();

const queryClient = useQueryClient();
const storage = useLocalStorage();

const [isJobLoggerVisible, setIsJobLoggerVisible] = useState(true);
Expand Down Expand Up @@ -422,6 +427,11 @@ const Sidebar = () => {
// @ts-expect-error
}, [getRolesQuery.data]);

useHandleWindowMessage({
[WindowMessageTypes.OFFER_MODERATED]: () =>
queryClient.invalidateQueries(['events']),
});

const announcements = useMemo(
() =>
rawAnnouncements.map((announcement) => {
Expand Down

0 comments on commit b5815eb

Please sign in to comment.