Fix API key not displayed (#9766)
Fixes #9761 Instead of cleaning RecoilState we should keep the api key visible as long as the user didn't refresh/leave the app, it's better from a UX perspective and the code is also more elegant, removing a useEffect Note: the root cause of the bug was a missing "/settings" path in isMatchingLocation in useCleaningRecoilState (due to the recent refactoring) ; but I think this fix is better
This commit is contained in:
@ -1,23 +0,0 @@
|
||||
import { apiKeyTokenState } from '@/settings/developers/states/generatedApiKeyTokenState';
|
||||
import { SettingsPath } from '@/types/SettingsPath';
|
||||
import { useRecoilValue, useResetRecoilState } from 'recoil';
|
||||
import { isDefined } from 'twenty-ui';
|
||||
import { useIsMatchingLocation } from '~/hooks/useIsMatchingLocation';
|
||||
|
||||
export const useCleanRecoilState = () => {
|
||||
const isMatchingLocation = useIsMatchingLocation();
|
||||
const resetApiKeyToken = useResetRecoilState(apiKeyTokenState);
|
||||
const apiKeyToken = useRecoilValue(apiKeyTokenState);
|
||||
const cleanRecoilState = () => {
|
||||
if (
|
||||
!isMatchingLocation(SettingsPath.DevelopersApiKeyDetail) &&
|
||||
isDefined(apiKeyToken)
|
||||
) {
|
||||
resetApiKeyToken();
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
cleanRecoilState,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user