Skip to content

Commit c09ba41

Browse files
authored
Merge pull request #50 from Nexus-Mods/bugfix-deployment-event-handlers-execution
Fixed deploy event handlers executing while managing other games
2 parents 3c51e93 + 63f754d commit c09ba41

3 files changed

Lines changed: 20 additions & 7 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).
66

7-
## 1.10.3 - 2024-11-07
7+
## [1.10.4] - 2024-12-09
8+
9+
- Fixed deployment event handlers executing while other games are managed
10+
11+
## [1.10.3] - 2024-11-07
812
- Fixed engine injectors (SFSE excluded) being erroneously flagged as the Game Pass ASI Loader
913

1014
## [1.10.2] - 2024-09-30

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "starfield",
3-
"version": "1.10.3",
3+
"version": "1.10.4",
44
"description": "Vortex Extension for Starfield",
55
"author": "Nexus Mods",
66
"private": true,

src/index.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,12 @@ const removePluginsWrap = (api: types.IExtensionApi) => {
122122
);
123123
};
124124

125+
const isCorrectGame = (api: types.IExtensionApi, profileId: string) => {
126+
const state = api.getState();
127+
const profile = selectors.profileById(state, profileId);
128+
return profile?.gameId === GAME_ID;
129+
};
130+
125131
function main(context: types.IExtensionContext) {
126132
context.registerReducer(['settings', 'starfield'], settingsReducer);
127133
// register a whole game, basic metadata and folder paths
@@ -249,9 +255,7 @@ async function onGameModeActivated(api: types.IExtensionApi) {
249255
}
250256

251257
async function onDidDeployEvent(api: types.IExtensionApi, profileId: string, deployment: types.IDeploymentManifest): Promise<void> {
252-
const state = api.getState();
253-
const gameId = selectors.profileById(state, profileId)?.gameId;
254-
if (gameId !== GAME_ID) {
258+
if (!isCorrectGame(api, profileId)) {
255259
return Promise.resolve();
256260
}
257261
await testDeprecatedFomod(api, false);
@@ -261,19 +265,24 @@ async function onDidDeployEvent(api: types.IExtensionApi, profileId: string, dep
261265
}
262266

263267
async function onWillPurgeEvent(api: types.IExtensionApi, profileId: string): Promise<void> {
268+
if (!isCorrectGame(api, profileId)) {
269+
return Promise.resolve();
270+
}
264271
const pluginsPath = await resolvePluginsFilePath(api);
265272
return fs.copyAsync(pluginsPath, PLUGINS_BACKUP, { overwrite: true }).catch((err) => null);
266273
}
267274

268275
async function onDidPurgeEvent(api: types.IExtensionApi, profileId: string): Promise<void> {
276+
if (!isCorrectGame(api, profileId)) {
277+
return Promise.resolve();
278+
}
269279
return linkAsiLoader(api, ASI_LOADER_BACKUP, TARGET_ASI_LOADER_NAME);
270280
}
271281

272282
async function onWillDeployEvent(api: types.IExtensionApi, profileId: any, deployment: types.IDeploymentManifest): Promise<void> {
273283
const state = api.getState();
274284
const pluginEnabler = util.getSafe(state, ['settings', 'starfield', 'pluginEnabler'], false);
275-
const profile = selectors.activeProfile(state);
276-
if (profile?.gameId !== GAME_ID || pluginEnabler === false) {
285+
if (!isCorrectGame(api, profileId) || pluginEnabler === false) {
277286
return Promise.resolve();
278287
}
279288
const discovery = selectors.discoveryByGame(state, GAME_ID);

0 commit comments

Comments
 (0)