From 8b0cd26c6f963036e5a9457e62d6e3e4eec9c5f6 Mon Sep 17 00:00:00 2001 From: Michael Hillcox Date: Tue, 19 Nov 2024 22:17:05 +0000 Subject: [PATCH] fix: minor issues with querying --- src/components/layout/AdAside.vue | 9 --------- src/modules/modpacks/types.ts | 5 +++++ src/views/InstancePage.vue | 20 ++++++++++++------- .../install/tasks/DownloadTask.java | 1 + .../util/CurseMetadataCache.java | 4 ++++ 5 files changed, 23 insertions(+), 16 deletions(-) diff --git a/src/components/layout/AdAside.vue b/src/components/layout/AdAside.vue index d759fab1..60ec24dd 100644 --- a/src/components/layout/AdAside.vue +++ b/src/components/layout/AdAside.vue @@ -58,7 +58,6 @@ import platform from '@/utils/interface/electron-overwolf'; import Component from 'vue-class-component'; import {Getter, State} from 'vuex-class'; import {SettingsState} from '@/modules/settings/types'; -import {JavaFetch} from '@/core/javaFetch'; import {createLogger} from '@/core/logger'; import {ns} from '@/core/state/appState'; import {MineTogetherAccount} from '@/core/@types/javaApi'; @@ -166,9 +165,6 @@ export default class AdAside extends Vue { this.ads[id].addEventListener('display_ad_loaded', () => { emitPlaceholderUpdate(false); this.logger.info(`[AD: ${id}] Display ad loaded and ready`); - JavaFetch.modpacksCh("analytics/ads/static") - .execute() - .catch(e => this.logger.error("Failed to send analytics", e)) }); this.ads[id].addEventListener('play', () => { emitPlaceholderUpdate(false); @@ -177,11 +173,6 @@ export default class AdAside extends Vue { this.ads[id].addEventListener('complete', () => { this.logger.info(`[AD: ${id}] Video ad finished playing`); }); - this.ads[id].addEventListener('impression', () => { - JavaFetch.modpacksCh("analytics/ads/video") - .execute() - .catch(e => this.logger.error("Failed to send analytics", e)) - }); } get advertsEnabled(): boolean { diff --git a/src/modules/modpacks/types.ts b/src/modules/modpacks/types.ts index 0925994a..fc4e865c 100644 --- a/src/modules/modpacks/types.ts +++ b/src/modules/modpacks/types.ts @@ -10,6 +10,8 @@ export interface ModPack { featured: boolean; refreshed: number; id: number; + slug: string; + sid: string; name: string; type: string; updated: number; @@ -19,6 +21,9 @@ export interface ModPack { links: ModPackLink[]; private?: boolean; provider: 'modpacks.ch' | 'curseforge' + meta?: { + supportsWorlds?: boolean; + } } export interface ModpackVersion { diff --git a/src/views/InstancePage.vue b/src/views/InstancePage.vue index 0875adf5..2ec38dea 100644 --- a/src/views/InstancePage.vue +++ b/src/views/InstancePage.vue @@ -198,13 +198,15 @@ export default class InstancePage extends Vue { } // TODO: (M#01) Allow to work without this. - this.apiPack = await this.getModpack({ - id: this.instance.id, - provider: typeIdToProvider(this.instance.packType) - }); - - if (!this.apiPack) { - this.activeTab = ModpackPageTabs.MODS; + if (this.instance.id !== -1) { + this.apiPack = await this.getModpack({ + id: this.instance.id, + provider: typeIdToProvider(this.instance.packType) + }); + + if (!this.apiPack) { + this.activeTab = ModpackPageTabs.MODS; + } } this.logger.debug("Loading backups") @@ -235,6 +237,10 @@ export default class InstancePage extends Vue { if (!this.instance?.versionId || !this.apiPack) { return; } + + if (this.instance.versionId === -1) { + return; + } const currentVersion = this.apiPack.versions.find((e) => e.id === this.instance?.versionId); if (!currentVersion || currentVersion.type.toLowerCase() !== 'archived') { diff --git a/subprocess/src/main/java/net/creeperhost/creeperlauncher/install/tasks/DownloadTask.java b/subprocess/src/main/java/net/creeperhost/creeperlauncher/install/tasks/DownloadTask.java index bab8947d..d3af49b3 100644 --- a/subprocess/src/main/java/net/creeperhost/creeperlauncher/install/tasks/DownloadTask.java +++ b/subprocess/src/main/java/net/creeperhost/creeperlauncher/install/tasks/DownloadTask.java @@ -217,6 +217,7 @@ private void doRequest(String url, OkHttpClient httpClient, Path path, DownloadV LOGGER.info(" Resume try {}.", tries); } + LOGGER.info(" Downloading url: {}", url); Request.Builder builder = new Request.Builder() .url(url) .addHeader("User-Agent", Constants.USER_AGENT); diff --git a/subprocess/src/main/java/net/creeperhost/creeperlauncher/util/CurseMetadataCache.java b/subprocess/src/main/java/net/creeperhost/creeperlauncher/util/CurseMetadataCache.java index bb39e0d0..9f6d5d80 100644 --- a/subprocess/src/main/java/net/creeperhost/creeperlauncher/util/CurseMetadataCache.java +++ b/subprocess/src/main/java/net/creeperhost/creeperlauncher/util/CurseMetadataCache.java @@ -159,6 +159,10 @@ private void save() { } private static @Nullable FileMetadata query(String murmur) { + if (murmur.equals("-1")) { + return null; + } + StringWriter sw = new StringWriter(); try { LOGGER.info("Querying metadata for {}", murmur);