Skip to content

Commit

Permalink
Merge pull request #83 from liamcain/fix-weekly-note-template-tags
Browse files Browse the repository at this point in the history
Fix weekly note template tags, remove console.log
  • Loading branch information
liamcain authored Dec 21, 2020
2 parents 0f41644 + df9a391 commit f9e1b9a
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 19 deletions.
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.6",
"version": "1.4.7",
"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.6",
"version": "1.4.7",
"description": "Calendar view of your daily notes",
"author": "liamcain",
"main": "main.js",
Expand Down
21 changes: 15 additions & 6 deletions src/io/weeklyNotes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,29 @@ import { createConfirmationDialog } from "src/ui/modal";

import { getNotePath } from "./path";

export function getDayOfWeekNumericalValue(dayOfWeekName: string): number {
function getDaysOfWeek(): string[] {
const { moment } = window;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const weekStart = (<any>moment.localeData())._week.dow;
let weekStart = (<any>moment.localeData())._week.dow;
const daysOfWeek = [
"sunday",
"monday",
"tuesday",
"wednesday",
"thursday",
"friday",
"saturday",
"sunday",
];
return (daysOfWeek.indexOf(dayOfWeekName.toLowerCase()) + weekStart) % 7;

while (weekStart) {
daysOfWeek.push(daysOfWeek.shift());
weekStart--;
}
return daysOfWeek;
}

export function getDayOfWeekNumericalValue(dayOfWeekName: string): number {
return getDaysOfWeek().indexOf(dayOfWeekName.toLowerCase());
}

export async function createWeeklyNote(
Expand Down Expand Up @@ -77,7 +86,7 @@ export async function tryToCreateWeeklyNote(
date: Moment,
inNewSplit: boolean,
settings: ISettings,
cb?: () => void
cb?: (file: TFile) => void
): Promise<void> {
const { workspace } = window.app;
const { format } = getWeeklyNoteSettings(settings);
Expand All @@ -90,7 +99,7 @@ export async function tryToCreateWeeklyNote(
: workspace.getUnpinnedLeaf();

await leaf.openFile(dailyNote);
cb?.();
cb?.(dailyNote);
};

if (settings.shouldConfirmBeforeCreate) {
Expand Down
4 changes: 1 addition & 3 deletions src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,7 @@ export class CalendarSettingsTab extends PluginSettingTab {
const { moment } = window;

const [sunday, monday] = moment.weekdays();

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const localeWeekStartNum = (<any>moment.localeData())._week.dow;
const localeWeekStartNum = window._bundledLocaleWeekSpec.dow;
const localeWeekStart = moment.weekdays()[localeWeekStartNum];

new Setting(this.containerEl)
Expand Down
1 change: 0 additions & 1 deletion src/ui/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ export function getMonthData(
let dailyNotes: IDailyNote[] = [];
try {
dailyNotes = getAllDailyNotes();
console.log("dailynotes", dailyNotes);
} catch (err) {
new Notice(err);
}
Expand Down
8 changes: 1 addition & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3337,18 +3337,12 @@ [email protected]:
obsidian obsidianmd/obsidian-api#master
tslib "2.0.3"

"obsidian@github:obsidianmd/obsidian-api#master":
obsidian@obsidianmd/obsidian-api#master:
version "0.10.0"
resolved "https://codeload.github.com/obsidianmd/obsidian-api/tar.gz/2e4ac7c8dd4d1b8ca4cf726eac75a935a3ea25d8"
dependencies:
"@types/codemirror" "0.0.98"

obsidian@obsidianmd/obsidian-api#master:
version "0.9.16"
resolved "https://codeload.github.com/obsidianmd/obsidian-api/tar.gz/3efab21fc0cfef3ae75951beb66aadd479ae610d"
dependencies:
"@types/codemirror" "0.0.98"

once@^1.3.0, once@^1.3.1, once@^1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
Expand Down

0 comments on commit f9e1b9a

Please sign in to comment.