Skip to content

Commit

Permalink
Generate a unique ID for each instance to prevent conflicts.
Browse files Browse the repository at this point in the history
  • Loading branch information
coddingtonbear committed Feb 11, 2024
1 parent ea81466 commit f4a1b95
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/popup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ import MentionNotice from "./components/MentionNotice";
import { NativeSelect, Paper } from "@mui/material";
import MouseOverChip from "./components/MouseOverChip";

const ROOT_CONTAINER_ID = "obsidian-web-container";

declare const BUILD_ID: string;
declare global {
interface Window {
ObsidianWeb: {
Expand All @@ -73,6 +72,8 @@ declare global {
}
}

const ROOT_CONTAINER_ID = `obsidian-web-container-${BUILD_ID}`;

if (!document.getElementById(ROOT_CONTAINER_ID)) {
function dispatchObsidianWebMessage(action: string, data?: any): void {
const evt = new CustomEvent("obsidian-web", {
Expand Down
6 changes: 6 additions & 0 deletions webpack/webpack.common.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
const path = require("path");
const CopyPlugin = require("copy-webpack-plugin");
const srcDir = path.join(__dirname, "..", "src");
const { DefinePlugin } = require("webpack");

const { v4: uuidv4 } = require("uuid");

module.exports = {
entry: {
Expand Down Expand Up @@ -48,5 +51,8 @@ module.exports = {
],
options: {},
}),
new DefinePlugin({
BUILD_ID: JSON.stringify(uuidv4()),
}),
],
};

0 comments on commit f4a1b95

Please sign in to comment.