mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +01:00 
			
		
		
		
	refactor: use splash api to store splash state (#8422)
To avoid showing the key concepts screen to users every time they log back in to Unleash (after logging out), store the state in the DB splash table. The reason we need to do this is that we clear localstorage on logging out, so things like splash screens and certain other settings don't get stored.
This commit is contained in:
		
							parent
							
								
									74370468d1
								
							
						
					
					
						commit
						d944eff34c
					
				@ -36,6 +36,8 @@ import {
 | 
			
		||||
import { ContentGridNoProjects } from './ContentGridNoProjects';
 | 
			
		||||
import ExpandMore from '@mui/icons-material/ExpandMore';
 | 
			
		||||
import { usePlausibleTracker } from 'hooks/usePlausibleTracker';
 | 
			
		||||
import useSplashApi from 'hooks/api/actions/useSplashApi/useSplashApi';
 | 
			
		||||
import { useAuthSplash } from 'hooks/api/getters/useAuth/useAuthSplash';
 | 
			
		||||
 | 
			
		||||
export const StyledCardTitle = styled('div')<{ lines?: number }>(
 | 
			
		||||
    ({ theme, lines = 2 }) => ({
 | 
			
		||||
@ -265,6 +267,8 @@ const NoActiveFlagsInfo = styled('div')(({ theme }) => ({
 | 
			
		||||
export const PersonalDashboard = () => {
 | 
			
		||||
    const { user } = useAuthUser();
 | 
			
		||||
    const { trackEvent } = usePlausibleTracker();
 | 
			
		||||
    const { setSplashSeen } = useSplashApi();
 | 
			
		||||
    const { splash } = useAuthSplash();
 | 
			
		||||
 | 
			
		||||
    const name = user?.name;
 | 
			
		||||
 | 
			
		||||
@ -285,7 +289,10 @@ export const PersonalDashboard = () => {
 | 
			
		||||
 | 
			
		||||
    const [welcomeDialog, setWelcomeDialog] = useLocalStorageState<
 | 
			
		||||
        'open' | 'closed'
 | 
			
		||||
    >('welcome-dialog:v1', 'open');
 | 
			
		||||
    >(
 | 
			
		||||
        'welcome-dialog:v1',
 | 
			
		||||
        splash?.personalDashboardKeyConcepts ? 'closed' : 'open',
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    const { personalDashboardProjectDetails, error: detailsError } =
 | 
			
		||||
        usePersonalDashboardProjectDetails(activeProject);
 | 
			
		||||
@ -299,9 +306,6 @@ export const PersonalDashboard = () => {
 | 
			
		||||
        !detailsError && activeProjectStage === 'loading',
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    const [createFlagDialogOpen, setCreateFlagDialogOpen] =
 | 
			
		||||
        React.useState(false);
 | 
			
		||||
 | 
			
		||||
    return (
 | 
			
		||||
        <MainContent>
 | 
			
		||||
            <WelcomeSection>
 | 
			
		||||
@ -449,7 +453,10 @@ export const PersonalDashboard = () => {
 | 
			
		||||
            </SectionAccordion>
 | 
			
		||||
            <WelcomeDialog
 | 
			
		||||
                open={welcomeDialog === 'open'}
 | 
			
		||||
                onClose={() => setWelcomeDialog('closed')}
 | 
			
		||||
                onClose={() => {
 | 
			
		||||
                    setSplashSeen('personalDashboardKeyConcepts');
 | 
			
		||||
                    setWelcomeDialog('closed');
 | 
			
		||||
                }}
 | 
			
		||||
            />
 | 
			
		||||
        </MainContent>
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user