Skip to content

Commit

Permalink
Fix semver compare on source builds (#310)
Browse files Browse the repository at this point in the history
* Fix semver compare on source builds

* Clarify semver comments

* Reclarify semver comments

* Fix semver compare
  • Loading branch information
thebluepotato authored Jan 12, 2025
1 parent f7bd475 commit 7289809
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/dialogs/editor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { createRoot } from "react-dom/client";
import Citation from "../../cita/citation";
import Wikicite from "../../cita/wikicite";
import { compareSemVer } from "semver-parser";
import ZoteroOverlay from "../../cita/zoteroOverlay";
import WikiciteChrome from "../../cita/wikiciteChrome";
import PID from "../../cita/PID";

Expand Down Expand Up @@ -119,9 +118,19 @@ window.addEventListener("load", () => {
const itemBoxLabel = document.createElement("h4");
itemBoxLabel.textContent = "Target"; //Wikicite.getString("wikicite.editor.title");
container.appendChild(itemBoxLabel);
// "item-box" was renamed to "info-box" in Zotero 7.0.10. We compare to 7.0.9 to include the beta versions.
const tagName =
compareSemVer(Zotero.version, "7.0.9") === 1 ? "info-box" : "item-box";
// "item-box" was renamed to "info-box" in Zotero 7.0.10, so check if we have at least this version of Zotero.
let semVerCompare: number;
try {
semVerCompare = compareSemVer(Zotero.version, "7.0.10");
} catch (e) {
// Zotero.version is not a valid semver string
// This may happen when installing certain beta versions or building Zotero from source, so we treat it as if it is at least Zotero 7.0.10
Zotero.log(
`Zotero version (${Zotero.version}) is not a valid semver string - maybe you installed a beta version or built it from source? Treating this version of Zotero as at least 7.0.10.`,
);
semVerCompare = 1;
}
const tagName = semVerCompare >= 0 ? "info-box" : "item-box";
const itemBox = document.createElementNS(
"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
tagName,
Expand Down
1 change: 1 addition & 0 deletions translators/zotkat
Submodule zotkat added at ece06e

0 comments on commit 7289809

Please sign in to comment.