diff --git a/services/web/frontend/extracted-translations.json b/services/web/frontend/extracted-translations.json index eeecf87e52..6a4109770c 100644 --- a/services/web/frontend/extracted-translations.json +++ b/services/web/frontend/extracted-translations.json @@ -799,7 +799,6 @@ "raw_logs": "", "raw_logs_description": "", "react_history_tutorial_content": "", - "react_history_tutorial_learn_more": "", "react_history_tutorial_title": "", "reactivate_subscription": "", "read_only": "", diff --git a/services/web/frontend/js/features/history/components/change-list/all-history-list.tsx b/services/web/frontend/js/features/history/components/change-list/all-history-list.tsx index 807155cfb4..b1cc9e9681 100644 --- a/services/web/frontend/js/features/history/components/change-list/all-history-list.tsx +++ b/services/web/frontend/js/features/history/components/change-list/all-history-list.tsx @@ -1,4 +1,4 @@ -import { useEffect, useRef, useState } from 'react' +import { useCallback, useEffect, useRef, useState } from 'react' import HistoryVersion from './history-version' import LoadingSpinner from '../../../../shared/components/loading-spinner' import { OwnerPaywallPrompt } from './owner-paywall-prompt' @@ -10,11 +10,15 @@ import { import { useUserContext } from '../../../../shared/context/user-context' import useDropdownActiveItem from '../../hooks/use-dropdown-active-item' import { useHistoryContext } from '../../context/history-context' -import getMeta from '../../../../utils/meta' +import { useEditorContext } from '../../../../shared/context/editor-context' type CompletedTutorials = { 'react-history-buttons-tutorial': Date } +type EditorTutorials = { + completedTutorials: CompletedTutorials + setCompletedTutorial: (key: string) => void +} const unselectedStates: ItemSelectionState[] = [ 'aboveSelected', @@ -97,14 +101,15 @@ function AllHistoryList() { } }, [updatesLoadingState]) - const completedTutorials: CompletedTutorials = getMeta( - 'ol-completedTutorials' - ) + const { completedTutorials, setCompletedTutorial }: EditorTutorials = + useEditorContext() // only show tutorial popover if they havent dismissed ("completed") it yet - const hasCompletedHistTutorial = Boolean( - completedTutorials?.['react-history-buttons-tutorial'] - ) + const showTutorial = !completedTutorials?.['react-history-buttons-tutorial'] + + const completeTutorial = useCallback(() => { + setCompletedTutorial('react-history-buttons-tutorial') + }, [setCompletedTutorial]) // only show tutorial popover on the first icon const firstUnselectedIndex = visibleUpdates.findIndex(update => { @@ -116,8 +121,6 @@ function AllHistoryList() { return unselectedStates.includes(selectionState) }) - const [showTutorial, setShowTutorial] = useState(!hasCompletedHistTutorial) - return (