From 3978613330afb1e4a6eac28ee1579b6ea6e815c5 Mon Sep 17 00:00:00 2001 From: Liam Cain Date: Tue, 19 Jan 2021 11:08:23 -0500 Subject: [PATCH] Add integration point for external CalendarSources (#116) * Add integration point for external CalendarSources * Keep streakSource for now * another attempt at fixing CI * Bump version --- .github/workflows/{ci.yml => main.yml} | 4 ++-- manifest.json | 2 +- package.json | 2 +- src/constants.ts | 2 ++ src/view.ts | 14 ++++++++++++-- 5 files changed, 18 insertions(+), 6 deletions(-) rename .github/workflows/{ci.yml => main.yml} (81%) diff --git a/.github/workflows/ci.yml b/.github/workflows/main.yml similarity index 81% rename from .github/workflows/ci.yml rename to .github/workflows/main.yml index e2ca867..90181ad 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/main.yml @@ -2,9 +2,9 @@ name: CI on: push: - branches: [$default-branch] + branches: [master] pull_request: - branches: [$default-branch] + branches: [master] jobs: lint-and-test: diff --git a/manifest.json b/manifest.json index f2d3b8a..0429dc2 100644 --- a/manifest.json +++ b/manifest.json @@ -2,7 +2,7 @@ "id": "calendar", "name": "Calendar", "description": "Calendar view of your daily notes", - "version": "1.4.14", + "version": "1.4.15", "author": "Liam Cain", "authorUrl": "https://github.com/liamcain/", "isDesktopOnly": false, diff --git a/package.json b/package.json index 1b8ab3c..15e9c54 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "calendar", - "version": "1.4.14", + "version": "1.4.15", "description": "Calendar view of your daily notes", "author": "liamcain", "main": "main.js", diff --git a/src/constants.ts b/src/constants.ts index 1977c1a..fa3fbd6 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -1,3 +1,5 @@ export const DEFAULT_WEEK_FORMAT = "gggg-[W]ww"; export const DEFAULT_WORDS_PER_DOT = 250; export const VIEW_TYPE_CALENDAR = "calendar"; + +export const TRIGGER_ON_OPEN = "calendar:open"; diff --git a/src/view.ts b/src/view.ts index 8eed9ba..799b4fd 100644 --- a/src/view.ts +++ b/src/view.ts @@ -7,7 +7,7 @@ import { import { FileView, TFile, ItemView, WorkspaceLeaf } from "obsidian"; import { get } from "svelte/store"; -import { VIEW_TYPE_CALENDAR } from "src/constants"; +import { TRIGGER_ON_OPEN, VIEW_TYPE_CALENDAR } from "src/constants"; import { tryToCreateDailyNote } from "src/io/dailyNotes"; import { getWeeklyNote, tryToCreateWeeklyNote } from "src/io/weeklyNotes"; import { getWeeklyNoteSettings, ISettings } from "src/settings"; @@ -79,6 +79,16 @@ export default class CalendarView extends ItemView { } async onOpen(): Promise { + // Integration point: external plugins can listen for `calendar:open` + // to feed in additional sources. + const sources = [ + customTagsSource, + streakSource, + wordCountSource, + tasksSource, + ]; + this.app.workspace.trigger(TRIGGER_ON_OPEN, sources); + dailyNotes.reindex(); this.calendar = new Calendar({ @@ -91,7 +101,7 @@ export default class CalendarView extends ItemView { onHoverWeek: this.onHoverWeek, onContextMenuDay: this.onContextMenuDay, onContextMenuWeek: this.onContextMenuWeek, - sources: [streakSource, customTagsSource, wordCountSource, tasksSource], + sources, }, }); }