Skip to content

Commit

Permalink
fix: minor issues with querying
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelHillcox committed Nov 19, 2024
1 parent 3bad3a9 commit 8b0cd26
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 16 deletions.
9 changes: 0 additions & 9 deletions src/components/layout/AdAside.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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);
Expand All @@ -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 {
Expand Down
5 changes: 5 additions & 0 deletions src/modules/modpacks/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export interface ModPack {
featured: boolean;
refreshed: number;
id: number;
slug: string;
sid: string;
name: string;
type: string;
updated: number;
Expand All @@ -19,6 +21,9 @@ export interface ModPack {
links: ModPackLink[];
private?: boolean;
provider: 'modpacks.ch' | 'curseforge'
meta?: {
supportsWorlds?: boolean;
}
}

export interface ModpackVersion {
Expand Down
20 changes: 13 additions & 7 deletions src/views/InstancePage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 8b0cd26

Please sign in to comment.