Skip to content

Commit

Permalink
Merge pull request ebkr#1253 from ebkr/vuex-in-profiles
Browse files Browse the repository at this point in the history
Use Vuex to access active game and settings in Profiles.vue
  • Loading branch information
anttimaki authored Mar 28, 2024
2 parents 2505ebf + 1c66a36 commit 6e8a583
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions src/pages/Profiles.vue
Original file line number Diff line number Diff line change
Expand Up @@ -259,11 +259,8 @@ import FileUtils from '../utils/FileUtils';
import InteractionProvider from '../providers/ror2/system/InteractionProvider';
import ManagerInformation from '../_managerinf/ManagerInformation';
import GameDirectoryResolverProvider from '../providers/ror2/game/GameDirectoryResolverProvider';
import GameManager from '../model/game/GameManager';
import Game from '../model/game/Game';
import { ProfileImportExport } from '../r2mm/mods/ProfileImportExport';
let settings: ManagerSettings;
let fs: FsProvider;
@Component({
Expand Down Expand Up @@ -297,8 +294,6 @@ export default class Profiles extends Vue {
private renamingProfile: boolean = false;
private activeGame!: Game;
get selectedProfile(): string {
return this.$store.getters['profile/activeProfileName'];
}
Expand Down Expand Up @@ -428,7 +423,7 @@ export default class Profiles extends Vue {
downloadImportedProfileMods(modList: ExportMod[], callback?: () => void) {
this.percentageImported = 0;
ThunderstoreDownloaderProvider.instance.downloadImportedMods(this.activeGame, modList,
ThunderstoreDownloaderProvider.instance.downloadImportedMods(this.$store.state.activeGame, modList,
(progress: number, modName: string, status: number, err: R2Error | null) => {
if (status == StatusEnum.FAILURE) {
this.importingProfile = false;
Expand Down Expand Up @@ -650,17 +645,13 @@ export default class Profiles extends Vue {
}
async created() {
this.activeGame = GameManager.activeGame;
fs = FsProvider.instance;
settings = await ManagerSettings.getSingleton(this.activeGame);
await settings.load();
const settings = await this.$store.getters.settings;
await this.$store.dispatch('profile/loadLastSelectedProfile');
// Set default paths
if (settings.getContext().gameSpecific.gameDirectory === null) {
const result = await GameDirectoryResolverProvider.instance.getDirectory(this.activeGame);
const result = await GameDirectoryResolverProvider.instance.getDirectory(this.$store.state.activeGame);
if (!(result instanceof R2Error)) {
await settings.setGameDirectory(result);
}
Expand Down

0 comments on commit 6e8a583

Please sign in to comment.