mirror of
https://github.com/sboulema/mtg-deck.git
synced 2026-07-22 06:50:39 +00:00
fix: Fix scorecard warnings
This commit is contained in:
parent
08953c8339
commit
38d450100f
6 changed files with 23 additions and 12 deletions
24
main.ts
24
main.ts
|
|
@ -14,7 +14,7 @@ import { ObsidianPluginMtgSettings } from "src/settings";
|
|||
import { parseCodeBlockOptions, applyShowOverrides } from "src/code-block-options";
|
||||
import { CollectionModal } from "src/collection-modal";
|
||||
import { renderCollection } from "src/collection-renderer";
|
||||
import { loadCache, getCache, clearCache } from "src/cache";
|
||||
import { loadCache, getCache, clearCache, CachedCardData } from "src/cache";
|
||||
|
||||
const DEFAULT_SETTINGS: ObsidianPluginMtgSettings = {
|
||||
collection: {
|
||||
|
|
@ -33,6 +33,16 @@ const DEFAULT_SETTINGS: ObsidianPluginMtgSettings = {
|
|||
},
|
||||
};
|
||||
|
||||
interface PluginData {
|
||||
settings?: Partial<ObsidianPluginMtgSettings>;
|
||||
collectionHash?: string;
|
||||
cardDataCache?: Record<string, CachedCardData>;
|
||||
}
|
||||
|
||||
const loadPluginData = async (plugin: Plugin): Promise<PluginData> => {
|
||||
return (await plugin.loadData() as PluginData) ?? {};
|
||||
};
|
||||
|
||||
export default class ObsidianPluginMtg extends Plugin {
|
||||
settings: ObsidianPluginMtgSettings;
|
||||
|
||||
|
|
@ -65,8 +75,8 @@ export default class ObsidianPluginMtg extends Plugin {
|
|||
|
||||
const hash = hashCollectionContents(this.collections);
|
||||
|
||||
const savedData = await this.loadData();
|
||||
if (savedData?.collectionHash === hash && savedData?.cardDataCache) {
|
||||
const savedData = await loadPluginData(this);
|
||||
if (savedData.collectionHash === hash && savedData.cardDataCache) {
|
||||
loadCache(savedData.cardDataCache);
|
||||
}
|
||||
});
|
||||
|
|
@ -114,7 +124,7 @@ export default class ObsidianPluginMtg extends Plugin {
|
|||
onunload() {
|
||||
void (async () => {
|
||||
const hash = hashCollectionContents(this.collections);
|
||||
const data = await this.loadData() ?? {};
|
||||
const data = await loadPluginData(this);
|
||||
|
||||
await this.saveData({
|
||||
...data,
|
||||
|
|
@ -126,16 +136,16 @@ export default class ObsidianPluginMtg extends Plugin {
|
|||
}
|
||||
|
||||
async loadSettings() {
|
||||
const data = await this.loadData();
|
||||
const data = await loadPluginData(this);
|
||||
this.settings = Object.assign(
|
||||
{},
|
||||
DEFAULT_SETTINGS,
|
||||
data?.settings as Partial<ObsidianPluginMtgSettings>
|
||||
data.settings
|
||||
);
|
||||
}
|
||||
|
||||
async saveSettings() {
|
||||
const data = await this.loadData() ?? {};
|
||||
const data = await loadPluginData(this);
|
||||
await this.saveData({
|
||||
...data,
|
||||
settings: this.settings,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"id": "mtg-deck",
|
||||
"name": "MTG Deck",
|
||||
"version": "1.14.128",
|
||||
"version": "1.14.129",
|
||||
"minAppVersion": "1.5.7",
|
||||
"description": "Display your MTG decks and card lists in your notes.",
|
||||
"author": "Samir Boulema",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "mtg-deck",
|
||||
"version": "1.14.128",
|
||||
"version": "1.14.129",
|
||||
"description": "Display your MTG decks and card lists in your notes.",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { CardData } from "./scryfall";
|
||||
|
||||
interface CachedCardData {
|
||||
export interface CachedCardData {
|
||||
data: CardData;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { App, Modal } from "obsidian";
|
||||
import { CardCollection, CardCounts } from "./collection";
|
||||
import { CardCollection } from "./collection";
|
||||
import { renderCollection } from "./collection-renderer";
|
||||
|
||||
export class CollectionModal extends Modal {
|
||||
|
|
|
|||
|
|
@ -28,5 +28,6 @@
|
|||
"1.12.88": "1.1.0",
|
||||
"1.13.105": "1.5.7",
|
||||
"1.13.106": "1.5.7",
|
||||
"1.14.128": "1.5.7"
|
||||
"1.14.128": "1.5.7",
|
||||
"1.14.129": "1.5.7"
|
||||
}
|
||||
Loading…
Reference in a new issue