From 37382a2cf594cac10c7b05120dc0742980a4ff84 Mon Sep 17 00:00:00 2001 From: Hongbo Wu Date: Fri, 12 May 2023 10:29:55 +0800 Subject: [PATCH] fix: show release notes after upgrade --- src/main.ts | 15 +++++++++++++++ src/settings/index.ts | 2 ++ src/settings/template.ts | 38 +++++++++++++++++++------------------- 3 files changed, 36 insertions(+), 19 deletions(-) diff --git a/src/main.ts b/src/main.ts index 8f0c3c4..443044d 100644 --- a/src/main.ts +++ b/src/main.ts @@ -40,6 +40,21 @@ export default class OmnivorePlugin extends Plugin { async onload() { await this.loadSettings(); await this.resetSyncingStateSetting(); + + // update version if needed + const latestVersion = this.manifest.version; + const currentVersion = this.settings.version; + if (latestVersion !== currentVersion) { + this.settings.version = latestVersion; + this.saveSettings(); + // show release notes + const releaseNotes = `Omnivore plugin is upgraded to ${latestVersion}. + + What's new: https://github.com/omnivore-app/obsidian-omnivore/blob/main/CHANGELOG.md + `; + new Notice(releaseNotes, 10000); + } + this.addCommand({ id: "sync", name: "Sync", diff --git a/src/settings/index.ts b/src/settings/index.ts index 4b1cdb3..9c212df 100644 --- a/src/settings/index.ts +++ b/src/settings/index.ts @@ -15,6 +15,7 @@ export const DEFAULT_SETTINGS: OmnivoreSettings = { endpoint: "https://api-prod.omnivore.app/api/graphql", filename: "{{{title}}}", attachmentFolder: "Omnivore/attachments", + version: "0.0.0", }; export enum Filter { @@ -43,4 +44,5 @@ export interface OmnivoreSettings { dateSavedFormat: string; filename: string; attachmentFolder: string; + version: string; } diff --git a/src/settings/template.ts b/src/settings/template.ts index 6b6fb80..1d5fc4a 100644 --- a/src/settings/template.ts +++ b/src/settings/template.ts @@ -68,24 +68,24 @@ export interface HighlightView { export type ArticleView = | { - id: string; - title: string; - omnivoreUrl: string; - siteName: string; - originalUrl: string; - author?: string; - labels?: LabelView[]; - dateSaved: string; - highlights: HighlightView[]; - content: string; - datePublished?: string; - fileAttachment?: string; - description?: string; - note?: string; - type: PageType; - dateRead?: string; - wordsCount?: number; - readLength?: number; + id: string; + title: string; + omnivoreUrl: string; + siteName: string; + originalUrl: string; + author?: string; + labels?: LabelView[]; + dateSaved: string; + highlights: HighlightView[]; + content: string; + datePublished?: string; + fileAttachment?: string; + description?: string; + note?: string; + type: PageType; + dateRead?: string; + wordsCount?: number; + readLength?: number; state: string; } | FunctionMap; @@ -100,7 +100,7 @@ enum ArticleState { const getArticleState = (article: Article): string => { if (article.isArchived) { return ArticleState.Archived; -} + } if (article.readingProgressPercent > 0) { return article.readingProgressPercent === 100 ? ArticleState.Completed