Skip to content

Commit

Permalink
chore: rename addon key in settings and upgrade version
Browse files Browse the repository at this point in the history
  • Loading branch information
debanjandhar12 committed May 4, 2024
1 parent 8e015dd commit ea0a75d
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "logseq-anki-sync",
"version": "6.3.0",
"version": "6.3.1",
"title": "Logseq Anki Sync",
"description": "An logseq to anki syncing plugin with superpowers - image occlusion, card direction, incremental cards, and a lot more.",
"main": "dist/index.html",
Expand Down
4 changes: 2 additions & 2 deletions src/addons/Addon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export abstract class Addon {
window.parent.LSPluginCore.reload([logseq.baseInfo.id]);
}
public isEnabled(): boolean {
const addons = logseq.settings.addons || [];
return addons.includes(this.getName());
const addonsList = logseq.settings.addonsList || [];
return addonsList.includes(this.getName());
}
}
8 changes: 4 additions & 4 deletions src/addons/AddonRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import {HideOcclusionData} from "./HideOcclusionData";
import {AnkiFeatureExplorer} from "./LogseqAnkiFeatureExplorer";

export class AddonRegistry {
public static addons: Addon[] = [];
public static addonsList: Addon[] = [];
public static add(addon: Addon) {
AddonRegistry.addons.push(addon);
AddonRegistry.addonsList.push(addon);
}
public static get(name: string): Addon {
return AddonRegistry.addons.find((addon) => addon.getName() === name);
return AddonRegistry.addonsList.find((addon) => addon.getName() === name);
}
public static getAll(): Addon[] {
return AddonRegistry.addons;
return AddonRegistry.addonsList;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/notes/NoteHashCalculator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default class NoteHashCalculator {
}
toHash.push(
_.omit(logseq.settings, [
"addons",
"addonsList",
"renderClozeMarcosInLogseq",
"hideClozeMarcosUntilHoverInLogseq",
"cacheLogseqAPIv1",
Expand Down
14 changes: 7 additions & 7 deletions src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const addSettingsToLogseq = () => {
type: "string",
title: "Default Deck:",
description:
"The default deck to use for cards when no deck property is specified.<br/> If <code>useNamespaceAsDefaultDeck</code> is enabled, this will be used as the default deck only when page is not in any namespace.",
"The default deck to use for cards when no deck property is specified.<br/> If <code>use-namespace-as-default-deck</code> is enabled, this will be used as the default deck only when page is not in any namespace.",
default: "Default",
},
{
Expand All @@ -79,14 +79,14 @@ export const addSettingsToLogseq = () => {
"When enabled, ({{c1 Hello}}, {{c2 World}}, ...) clozes will be hidden by default and displayed only on hover.",
},
{
key: "addons",
key: "addonsList",
type: "enum",
default: AddonRegistry.getAll().map((addon) => addon.getName()),
title: "Addons:",
enumChoices: AddonRegistry.getAll().map((addon) => addon.getName()),
enumPicker: "checkbox",
description:
"Select the addons to use. They add additional features to the plugin."
"Select the addons to use. They add / modify gui elements to enhance plugin capabilities inside Logseq."
},
{
key: "advancedSettingsHeading",
Expand Down Expand Up @@ -137,12 +137,12 @@ export const addSettingsToLogseq = () => {
];
LogseqProxy.Settings.useSettingsSchema(settingsTemplate);
LogseqProxy.Settings.registerSettingsChangeListener((newSettings, oldSettings) => {
if (oldSettings.addons === undefined) oldSettings.addons = [];
if (!_.isEqual(newSettings.addons, oldSettings.addons)) {
for (const addon of oldSettings.addons) {
if (oldSettings.addonsList === undefined) oldSettings.addonsList = [];
if (!_.isEqual(newSettings.addonsList, oldSettings.addonsList)) {
for (const addon of oldSettings.addonsList) {
AddonRegistry.get(addon).remove();
}
for (const addon of newSettings.addons) {
for (const addon of newSettings.addonsList) {
AddonRegistry.get(addon).init();
}
}
Expand Down

0 comments on commit ea0a75d

Please sign in to comment.