import { MainWindowState } from '../../../../../models/mainwindow/main-window-state' ; import { NavigationAchievements } from '../../../../../models/mainwindow/navigation/navigation-achievements' ; import { NavigationState } from '../../../../../models/mainwindow/navigation/navigation-state' ; import { ShowAchievementDetailsEvent } from '../../events/achievements/show-achievement-details-event' ; import { Processor } from '../processor' ; export class ShowAchievementDetailsProcessor implements Processor { public async process ( event , currentState , history , navigationState ) { const [ categoryHierarchy , visualAchievement ] = currentState . achievements . findAchievementHierarchy ( event . achievementId ) ; if ( ! categoryHierarchy || categoryHierarchy . length === 0 || ! visualAchievement ) { return [ null , null ] ; } const achievement = visualAchievement . completionSteps [ 0 ] . id ; const newAchievements = navigationState . navigationAchievements . update ( { currentView : 'list' , menuDisplayType : 'breadcrumbs' , selectedCategoryId : categoryHierarchy [ categoryHierarchy . length - 1 ] . id , displayedAchievementsList : categoryHierarchy [ categoryHierarchy . length - 1 ] . achievements . map ( ( ach ) => ach . id ) as readonly string [ ] , selectedAchievementId : achievement , } as NavigationAchievements ) ; const text = categoryHierarchy . map ( ( cat ) => cat . name ) . join ( ' ' ) ; return [ null , navigationState . update ( { isVisible : true , currentApp : 'achievements' , navigationAchievements : newAchievements , text : text , image : null , } as NavigationState ) , ] ; } }