Skip to content

Commit

Permalink
Add integration point for external CalendarSources (#116)
Browse files Browse the repository at this point in the history
* Add integration point for external CalendarSources

* Keep streakSource for now

* another attempt at fixing CI

* Bump version
  • Loading branch information
liamcain authored Jan 19, 2021
1 parent dfb9d96 commit 3978613
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml → .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: CI

on:
push:
branches: [$default-branch]
branches: [master]
pull_request:
branches: [$default-branch]
branches: [master]

jobs:
lint-and-test:
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 2 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
@@ -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";
14 changes: 12 additions & 2 deletions src/view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -79,6 +79,16 @@ export default class CalendarView extends ItemView {
}

async onOpen(): Promise<void> {
// 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({
Expand All @@ -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,
},
});
}
Expand Down

0 comments on commit 3978613

Please sign in to comment.