import { Injectable } from '@angular/core' ; import { DeckFilters } from '../../../models/mainwindow/decktracker/deck-filters' ; import { DeckSummary } from '../../../models/mainwindow/decktracker/deck-summary' ; import { DecktrackerState } from '../../../models/mainwindow/decktracker/decktracker-state' ; import { StatsState } from '../../../models/mainwindow/stats/stats-state' ; import { PatchInfo } from '../../../models/patches' ; import { Preferences } from '../../../models/preferences' ; import { DecksStateBuilderService } from './decks-state-builder.service' ; @ Injectable ( ) export class DecktrackerStateLoaderService { constructor ( private readonly decksStateBuilder ) { } public buildState ( currentState , stats , patch = null , prefs = null ) { const existingFilters = prefs ?. desktopDeckFilters ?? currentState . filters ?? new DeckFilters ( ) ; const filters = { gameFormat : existingFilters . gameFormat ?? 'all' , gameMode : existingFilters . gameMode ?? 'ranked' , time : existingFilters . time ?? 'all-time' , sort : existingFilters . sort ?? 'last-played' , rank : existingFilters . rank ?? 'all' , rankingGroup : existingFilters . rankingGroup ?? 'per-match' , rankingCategory : existingFilters . rankingCategory ?? 'leagues' , } ; const decks = this . decksStateBuilder . buildState ( stats , filters , patch , prefs ) ; patch = patch || currentState . patch ; return Object . assign ( new DecktrackerState ( ) , currentState , { decks : decks , filters : filters , isLoading : false , showHiddenDecks : prefs ?. desktopDeckShowHiddenDecks ?? false , patch : patch , } as DecktrackerState ) ; } }