Skip to content

Commit

Permalink
Fixes:
Browse files Browse the repository at this point in the history
- Fixed mod list refresh issue on re-open

- Prevented image links opening via internal browser

- Incorrect README and CHANGELOG can no longer appear if loaded after a new selected README/CHANGELOG has been loaded.
  • Loading branch information
ebkr committed Mar 2, 2025
1 parent 7010ae5 commit 70b4391
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 16 deletions.
20 changes: 13 additions & 7 deletions src/components/v2/MarkdownRender.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,21 @@ const markdownToRender = computed(() => {
return md.render(props.markdown);
})
function capturePropagationParentLink(target: HTMLElement, originalEvent: Event) {
if (target.tagName.toLowerCase() === "a") {
const href = target.getAttribute("href") || "";
if (!href.startsWith("#")) {
originalEvent.preventDefault();
LinkProvider.instance.openLink(target.getAttribute("href")!);
}
} else if (target.parentElement) {
capturePropagationParentLink(target.parentElement, originalEvent);
}
}
function captureClick(e: Event) {
if (e.target && e.target instanceof HTMLElement) {
if (e.target.tagName.toLowerCase() === "a") {
const href = e.target.getAttribute("href") || "";
if (!href.startsWith("#")) {
e.preventDefault();
LinkProvider.instance.openLink(e.target.getAttribute("href")!);
}
}
capturePropagationParentLink(e.target, e);
}
return e;
}
Expand Down
26 changes: 19 additions & 7 deletions src/components/v2/OnlinePreviewPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,28 @@ function fetchDataFor(mod: ThunderstoreMod, type: "readme" | "changelog"): Promi
.then(res => res.markdown);
}
function fetchReadme() {
return fetchDataFor(props.mod, "readme").then(res => readme.value = res);
function fetchReadme(modToLoad: ThunderstoreMod) {
return fetchDataFor(props.mod, "readme").then(res => {
if (props.mod === modToLoad) {
readme.value = res;
}
});
}
function fetchChangelog() {
return fetchDataFor(props.mod, "changelog").then(res => changelog.value = res);
function fetchChangelog(modToLoad: ThunderstoreMod) {
return fetchDataFor(props.mod, "changelog").then(res => {
if (props.mod === modToLoad) {
changelog.value = res;
}
});
}
function fetchAll(modToLoad: ThunderstoreMod) {
loadingPanel.value = true;
buildDependencies(modToLoad)
.then(value => dependencies.value = value)
.then(fetchReadme)
.then(fetchChangelog)
.then(() => fetchReadme(modToLoad))
.then(() => fetchChangelog(modToLoad))
.then(() => {
if (props.mod === modToLoad) {
loadingPanel.value = false;
Expand Down Expand Up @@ -119,7 +127,11 @@ const markdownToRender = computed(() => {
</div>
<div class="c-preview-panel__content">
<template v-if="loadingPanel">
<p>Getting content</p>
<div class="notification">
<div class="container">
<p>Fetching {{ activeTab }} for {{ props.mod.getFullName() }}</p>
</div>
</div>
</template>
<template v-else-if="activeTab === 'Dependencies'">
<template v-if="dependencies.length > 0">
Expand Down
10 changes: 8 additions & 2 deletions src/store/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Vue from 'vue';
import Vuex, { ActionContext } from 'vuex';
import Vuex, { ActionContext, Store } from 'vuex';

import ErrorModule from './modules/ErrorModule';
import { DownloadModule } from './modules/DownloadModule';
Expand Down Expand Up @@ -141,5 +141,11 @@ export const store = {
* If not building with SSR mode, you can
* directly export the Store instantiation
*/
let singletonStore!: Store<State>;

export default (/* { ssrContext } */) => new Vuex.Store<State>(store);
export default (/* { ssrContext } */) => {
if (!singletonStore) {
singletonStore = new Store<State>(store);
}
return singletonStore;
};

0 comments on commit 70b4391

Please sign in to comment.