mirror of
https://git.quad4.io/RNS-Things/MeshChatX.git
synced 2026-05-11 07:26:53 +00:00
refactor(NomadNetworkPage): improve logic for determining .mu page rendering and update related tests
This commit is contained in:
@@ -151,7 +151,7 @@
|
||||
</template>
|
||||
|
||||
<div
|
||||
v-if="wasmBundled && (nodePagePath || '').toLowerCase().endsWith('.mu')"
|
||||
v-if="showMicronRendererInMobileMenu"
|
||||
class="mt-2 pt-2 border-t border-[var(--mc-border-strong)] flex flex-col gap-1.5"
|
||||
>
|
||||
<div
|
||||
@@ -757,13 +757,23 @@ export default {
|
||||
}
|
||||
return null;
|
||||
},
|
||||
showMicronRendererInMobileMenu() {
|
||||
if (!this.wasmBundled || !this.selectedNode || !this.nodePagePath || this.isShowingNodePageSource) {
|
||||
/**
|
||||
* True when the loaded Nomad URL points at a .mu page. Strips Nomad ` suffix
|
||||
* (e.g. /page/foo.mu`g=reticulum|...) so engine switching matches the renderer chip.
|
||||
*/
|
||||
nodePagePathIsMicronMu() {
|
||||
if (!this.nodePagePath) {
|
||||
return false;
|
||||
}
|
||||
const [p] = this.nodePagePath.split("`");
|
||||
return (p || "").toLowerCase().endsWith(".mu");
|
||||
},
|
||||
showMicronRendererInMobileMenu() {
|
||||
if (!this.wasmBundled || !this.selectedNode || !this.nodePagePath || this.isShowingNodePageSource) {
|
||||
return false;
|
||||
}
|
||||
return this.nodePagePathIsMicronMu;
|
||||
},
|
||||
blockedDestinations() {
|
||||
return GlobalState.blockedDestinations;
|
||||
},
|
||||
@@ -916,7 +926,7 @@ export default {
|
||||
this.$watch(
|
||||
() => GlobalState.config?.nomad_micron_default_engine,
|
||||
() => {
|
||||
if (this.nodePageContent && this.nodePagePath && this.nodePagePath.toLowerCase().endsWith(".mu")) {
|
||||
if (this.nodePageContent && this.nodePagePathIsMicronMu) {
|
||||
const content = this.nodePageContent;
|
||||
this.nodePageContent = null;
|
||||
this.$nextTick(() => {
|
||||
@@ -1010,7 +1020,7 @@ export default {
|
||||
try {
|
||||
const cfg = await patchServerConfig({ nomad_micron_default_engine: next }, window.api);
|
||||
mergeGlobalConfig(cfg);
|
||||
if (this.nodePageContent && this.nodePagePath && this.nodePagePath.toLowerCase().endsWith(".mu")) {
|
||||
if (this.nodePageContent && this.nodePagePathIsMicronMu) {
|
||||
const content = this.nodePageContent;
|
||||
this.nodePageContent = null;
|
||||
this.$nextTick(() => {
|
||||
|
||||
@@ -180,6 +180,19 @@ describe("NomadNetworkPage.vue", () => {
|
||||
});
|
||||
expect(wrapper.vm.showMicronRendererInMobileMenu).toBe(false);
|
||||
});
|
||||
|
||||
it("is true on .mu page when URL has Nomad data suffix after backtick", async () => {
|
||||
const dest = "e".repeat(32);
|
||||
const wrapper = mountNomadNetworkPage();
|
||||
await wrapper.setData({
|
||||
wasmBundled: true,
|
||||
selectedNode: { destination_hash: dest, display_name: "N" },
|
||||
nodePagePath: `${dest}:/page/repo.mu\`g=reticulum|r=nomadnet`,
|
||||
isShowingNodePageSource: false,
|
||||
});
|
||||
expect(wrapper.vm.nodePagePathIsMicronMu).toBe(true);
|
||||
expect(wrapper.vm.showMicronRendererInMobileMenu).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("partials", () => {
|
||||
|
||||
Reference in New Issue
Block a user