From c3a5d288d9a38a52729b773e1b9662b7389ee6a4 Mon Sep 17 00:00:00 2001 From: Michael Hillcox Date: Thu, 8 Aug 2024 12:40:40 +0100 Subject: [PATCH] fix: refresh instances on migration complete --- package.json | 2 +- src/views/MainApp.vue | 8 +++++++- .../api/data/other/RequestInstanceRefresh.java | 9 +++++++++ .../MigrateJVMDefaultsToInstances.java | 7 +++++++ vue.config.js | 18 ------------------ 5 files changed, 24 insertions(+), 20 deletions(-) create mode 100644 subprocess/src/main/java/net/creeperhost/creeperlauncher/api/data/other/RequestInstanceRefresh.java diff --git a/package.json b/package.json index 0c8a44de..2623c7ff 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "productName": "FTB Electron App", "name": "ftb-app", - "version": "1.25.17", + "version": "1.25.18", "private": true, "main": "background.js", "email": "admin@feed-the-beast.com", diff --git a/src/views/MainApp.vue b/src/views/MainApp.vue index 3b385dda..59a8122b 100644 --- a/src/views/MainApp.vue +++ b/src/views/MainApp.vue @@ -76,7 +76,7 @@ import os from 'os'; import {constants} from '@/core/constants'; import {SetAccountMethod, SetProfileMethod} from '@/core/state/core/mtAuthState'; import {StoreCredentialsAction} from '@/core/state/core/apiCredentialsState'; -import {adsEnabled} from '@/utils'; +import {adsEnabled, emitter} from '@/utils'; import {MineTogetherAccount} from '@/core/@types/javaApi'; import Loader from '@/components/atoms/Loader.vue'; import Onboarding from '@/components/core/dialogs/Onboarding.vue'; @@ -192,6 +192,12 @@ export default class MainApp extends Vue { await this.startApp(); this.appLoaded = true; + + emitter.on("ws.message", (data: any) => { + if (data?.type === "refreshInstancesRequest") { + this.loadInstances(); + } + }) } async initApp() { diff --git a/subprocess/src/main/java/net/creeperhost/creeperlauncher/api/data/other/RequestInstanceRefresh.java b/subprocess/src/main/java/net/creeperhost/creeperlauncher/api/data/other/RequestInstanceRefresh.java new file mode 100644 index 00000000..a507e9ef --- /dev/null +++ b/subprocess/src/main/java/net/creeperhost/creeperlauncher/api/data/other/RequestInstanceRefresh.java @@ -0,0 +1,9 @@ +package net.creeperhost.creeperlauncher.api.data.other; + +import net.creeperhost.creeperlauncher.api.data.BaseData; + +public class RequestInstanceRefresh extends BaseData { + public RequestInstanceRefresh() { + this.type = "refreshInstancesRequest"; + } +} diff --git a/subprocess/src/main/java/net/creeperhost/creeperlauncher/migration/migrations/MigrateJVMDefaultsToInstances.java b/subprocess/src/main/java/net/creeperhost/creeperlauncher/migration/migrations/MigrateJVMDefaultsToInstances.java index fbbe6d50..85f7a40e 100644 --- a/subprocess/src/main/java/net/creeperhost/creeperlauncher/migration/migrations/MigrateJVMDefaultsToInstances.java +++ b/subprocess/src/main/java/net/creeperhost/creeperlauncher/migration/migrations/MigrateJVMDefaultsToInstances.java @@ -2,6 +2,8 @@ import net.creeperhost.creeperlauncher.Constants; import net.creeperhost.creeperlauncher.Instances; +import net.creeperhost.creeperlauncher.api.WebSocketHandler; +import net.creeperhost.creeperlauncher.api.data.other.RequestInstanceRefresh; import net.creeperhost.creeperlauncher.migration.Migration; import net.creeperhost.creeperlauncher.pack.Instance; import org.slf4j.Logger; @@ -50,4 +52,9 @@ public boolean migrate() { return true; } + + @Override + public void cleanup() { + WebSocketHandler.sendMessage(new RequestInstanceRefresh()); + } } diff --git a/vue.config.js b/vue.config.js index 0a88a977..c4e6d2c2 100644 --- a/vue.config.js +++ b/vue.config.js @@ -1,5 +1,4 @@ const path = require('path'); -// const SentryWebpackPlugin = require('@sentry/webpack-plugin'); const {globSync} = require("glob"); const fs = require('fs'); const {execSync} = require('child_process'); @@ -9,23 +8,6 @@ const packageJson = JSON.parse(fs.readFileSync('package.json', 'utf-8')); const webpackPlugins = []; -// if (process.env.GITHUB_REF_NAME) { -// webpackPlugins.push( -// new SentryWebpackPlugin({ -// authToken: process.env.SENTRY_AUTH_TOKEN, -// org: 'creeperhost', -// project: 'ftb-app', -// release: `${packageJson.version}`, -// dist: process.env.APP_TARGET_PLATFORM ?? "unknown", -// include: process.env.TARGET_PLATFORM === 'overwolf' ? './overwolf/dist/desktop/' : './dist_electron/bundled/', -// ignore: ['node_modules', 'webpack.config.js'], -// urlPrefix: process.env.TARGET_PLATFORM === 'overwolf' -// ? `overwolf-extension://cmogmmciplgmocnhikmphehmeecmpaggknkjlbag/dist/desktop/` -// : "ftb://./" -// }), -// ); -// } - // This is required, the amount of times the IDE will import this just for using the variable is insane if (process.env.GITHUB_REF_NAME) { console.log("Checking for bad imports")