Skip to content

Commit

Permalink
hide previews notice when a notice is called from javascript
Browse files Browse the repository at this point in the history
  • Loading branch information
haouarihk committed Mar 9, 2024
1 parent 0f830c1 commit 43c3872
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/helpers/javascript-sandbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ export default async function runJSInSandbox(
script: string,
self: { plugin: TextGeneratorPlugin } & Record<any, any>
) {
let mainNotice:any;

const sandbox: Record<any, any> = {
JSON5,
lodashGet,
Expand All @@ -42,7 +44,8 @@ export default async function runJSInSandbox(
...self,

notice(context: any, duration: any) {
new Notice(context, typeof duration == "object" ? undefined : +duration);
if(mainNotice) mainNotice.hide();
return mainNotice = new Notice(context, typeof duration == "object" ? undefined : +duration);
},
async deleteFile(path: string) {
return await self.plugin.app.vault.adapter.remove(path);
Expand Down

0 comments on commit 43c3872

Please sign in to comment.