@@ -5,7 +5,9 @@ import ContentEditable from 'react-contenteditable'
55import { Params , useLocation , useParams } from 'react-router-dom'
66import { toast } from 'react-toastify'
77import sanitizeHtml from 'sanitize-html'
8- import { KeyedMutator } from 'swr'
8+ import { KeyedMutator , useSWRConfig } from 'swr'
9+ // tslint:disable-next-line: no-submodule-imports
10+ import { FullConfiguration } from 'swr/dist/types'
911
1012import { Breadcrumb , BreadcrumbItemModel , Button , ButtonProps , ContentLayout , IconOutline , IconSolid , LoadingSpinner , PageDivider , Sort , tableGetDefaultSort , TabsNavbar , TabsNavItem } from '../../../../lib'
1113import { GamificationConfig } from '../../game-config'
@@ -79,8 +81,7 @@ const BadgeDetailPage: FC = () => {
7981
8082 const [ showActivatedModal , setShowActivatedModal ] : [ boolean , Dispatch < SetStateAction < boolean > > ] = useState < boolean > ( false )
8183
82- const [ forceAwardedMembersTabRefresh , setForceAwardedMembersTabRefresh ] : [ boolean | undefined , Dispatch < SetStateAction < boolean | undefined > > ]
83- = useState < boolean | undefined > ( )
84+ const { cache, mutate } : FullConfiguration = useSWRConfig ( )
8485
8586 useEffect ( ( ) => {
8687 if ( newImageFile && newImageFile . length ) {
@@ -266,15 +267,19 @@ const BadgeDetailPage: FC = () => {
266267
267268 function onAssign ( ) : void {
268269 // refresh awardedMembers data
269- setForceAwardedMembersTabRefresh ( true )
270+ // for all keys in the cache, containing `assignees`
271+ ( cache as Map < string , any > ) . forEach ( ( v , key ) => {
272+ if ( key . startsWith ( 'https' ) && key . includes ( 'assignees' ) ) {
273+ mutate ( key , undefined )
274+ }
275+ } )
270276 setActiveTab ( BadgeDetailsTabViews . awardedMembers )
271277 }
272278
273279 // default tab
274280 let activeTabElement : JSX . Element
275281 = < AwardedMembersTab
276282 badge = { badgeDetailsHandler . data as GameBadge }
277- forceRefresh = { forceAwardedMembersTabRefresh }
278283 />
279284 if ( activeTab === BadgeDetailsTabViews . manualAward ) {
280285 activeTabElement = < ManualAwardTab
0 commit comments