Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 32 additions & 8 deletions src/app/container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,17 @@
'use strict';

import * as vscode from 'vscode';
import { IConfiguration, IFileSystem, ILogger, IWorkspaceConfigReader, JournalController } from '../model';
import { Configuration } from '../vscode/conf';
import { Parser } from '../journal/parser';
import { Writer } from '../journal/writer';
import { Reader } from '../journal/reader';
import { Inject } from '../journal/inject';
import { Dialogues } from '../vscode/dialogues';
import { VscodeFileSystem } from '../vscode/vscode-fs';
import { IConfiguration, IFileSystem, ILogger, IWorkspaceConfigReader, JournalController } from '../shared/model/index';
import { Configuration } from '../shared/config/configuration';
import { Parser } from '../features/smart-input/parser';
import { Writer } from '../features/entries/writer';
import { Reader } from '../features/entries/reader';
import { Inject } from '../features/entries/inject';
import { Dialogues } from '../features/smart-input/dialogues';
import { VscodeFileSystem } from '../shared/fs/vscode-fs';
import { JournalEvents } from '../shared/events';
import { getWeekFromURIAndConfig } from '../shared/paths';
import { SyncDailyLinks } from '../features/weekly/sync-daily-links';

/**
* Builds the logger once the configuration is available. The logger needs the
Expand All @@ -51,6 +54,7 @@ export class Container implements JournalController {
public readonly ui: Dialogues;
public readonly writer: Writer;
public readonly reader: Reader;
public readonly events: JournalEvents;

constructor(configSource: IWorkspaceConfigReader, loggerFactory: LoggerFactory) {
this.config = new Configuration(configSource);
Expand All @@ -62,5 +66,25 @@ export class Container implements JournalController {
this.writer = new Writer(this.config, this.logger, this.inject, this.fs,
async (path) => vscode.workspace.openTextDocument(vscode.Uri.file(path)));
this.reader = new Reader(this.config, this.logger, this.writer, this.ui, this.fs);
this.events = new JournalEvents();

// Cross-feature: when an entry opens, the weekly feature refreshes its
// daily-entry links. Wired here (composition root) so the entries
// feature need not import the weekly feature.
this.events.onEntryOpened(({ doc }) => this.syncWeeklyOnEntryOpened(doc));
}

private syncWeeklyOnEntryOpened(doc: vscode.TextDocument): void {
// Fire-and-forget — must never reject the open flow.
getWeekFromURIAndConfig(doc.uri, this.config)
.then(weekInfo => {
if (weekInfo && this.config.getWeeklySyncConfig().enabled) {
const scopeId = weekInfo.scope === 'default' ? undefined : weekInfo.scope;
new SyncDailyLinks(this)
.sync(doc, weekInfo.week, weekInfo.year, scopeId)
.catch(err => this.logger.error("entryOpened weekly sync failed:", err));
}
})
.catch(err => this.logger.error("entryOpened getWeekFromURIAndConfig failed:", err));
}
}
25 changes: 17 additions & 8 deletions src/app/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,23 @@

import * as vscode from 'vscode';
import { Container } from './container';
import {
OpenJournalWorkspaceCommand, OpenNextEntryCommand, OpenPreviousEntryCommand,
PrintDurationCommand, PrintSumCommand, PrintTimeCommand, ShiftTaskCommand,
ShowEntryForInputCommand, ShowEntryForTodayCommand, ShowEntryForTomorrowCommand,
ShowEntryForYesterdayCommand, ShowNoteCommand,
} from '../commands';
import { SyncDailyLinks, SyncNoteLinks, WeeklyEntryWatcher } from '../features';
import { CompletedTaskActions, OpenTaskActions } from '../ui';
import { OpenJournalWorkspaceCommand } from '../features/tools/commands/open-journal-workspace';
import { PrintTimeCommand } from '../features/tools/commands/print-current-time';
import { PrintDurationCommand } from '../features/tools/commands/print-duration-between-selected-times';
import { PrintSumCommand } from '../features/tools/commands/print-sum-of-selected-numbers';
import { CopyTaskCommand as ShiftTaskCommand } from '../features/tasks/commands/copy-task';
import { OpenNextEntryCommand } from '../features/navigation/commands/open-next-entry';
import { OpenPreviousEntryCommand } from '../features/navigation/commands/open-previous-entry';
import { ShowEntryForInputCommand } from '../features/entries/commands/show-entry-for-input';
import { ShowEntryForTodayCommand } from '../features/entries/commands/show-entry-for-today';
import { ShowEntryForTomorrowCommand } from '../features/entries/commands/show-entry-for-tomorrow';
import { ShowEntryForYesterdayCommand } from '../features/entries/commands/show-entry-for-yesterday';
import { ShowNoteCommand } from '../features/notes/commands/show-note';
import { WeeklyEntryWatcher } from '../features/weekly/weekly-entry-watcher';
import { SyncDailyLinks } from '../features/weekly/sync-daily-links';
import { SyncNoteLinks } from '../features/notes/sync-note-links';
import { CompletedTaskActions } from '../features/tasks/codeactions/for-completed-tasks';
import { OpenTaskActions } from '../features/tasks/codeactions/for-open-tasks';

const MARKDOWN_SELECTOR: vscode.DocumentSelector = { scheme: 'file', language: 'markdown' };

Expand Down
4 changes: 2 additions & 2 deletions src/app/startup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@

import * as vscode from 'vscode';
import * as Path from 'path';
import { isNullOrUndefined, ConsoleLogger } from '../util';
import { Configuration } from '../vscode/conf';
import { isNullOrUndefined, ConsoleLogger } from '../shared/index';
import { Configuration } from '../shared/config/configuration';
import { Container } from './container';
import { registerCacheInvalidation, registerCodeActions, registerCommands } from './register';

Expand Down
12 changes: 0 additions & 12 deletions src/commands/index.ts

This file was deleted.

4 changes: 2 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@


import * as vscode from 'vscode';
import { Configuration } from './vscode';
import { Startup } from './app';
import { Configuration } from './shared/config/configuration';
import { Startup } from './app/index';

export var journalStartup: Startup;
export var journalConfiguration: Configuration;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@
'use strict';

import * as vscode from 'vscode';
import { LoadNotes } from '../features';
import { JournalController, Input } from '../model';
import { NoteInput, SelectedInput, ScopedTemplate } from '../model';
import { getWeekFromURIAndConfig, isRemoteSession, toLocalFileUri } from '../journal/paths';
import { SyncDailyLinks } from '../features/sync/sync-daily-links';
import { LoadNotes } from '../../notes/load-note';
import { JournalController, Input } from '../../../shared/model/index';
import { NoteInput, SelectedInput, ScopedTemplate } from '../../../shared/model/index';
import { isRemoteSession, toLocalFileUri } from '../../../shared/paths';


export class AbstractLoadEntryForDateCommand implements vscode.Disposable {
Expand Down Expand Up @@ -131,17 +130,8 @@ export class AbstractLoadEntryForDateCommand implements vscode.Disposable {
return this.ctrl.reader.loadEntryForInput(input)
.then((doc: vscode.TextDocument) => this.ctrl.inject.injectInput(doc, input))
.then((doc: vscode.TextDocument) => {
// Fire-and-forget weekly sync — must never reject loadPageForInput.
getWeekFromURIAndConfig(doc.uri, this.ctrl.config)
.then(weekInfo => {
if (weekInfo && this.ctrl.config.getWeeklySyncConfig().enabled) {
const scopeId = weekInfo.scope === 'default' ? undefined : weekInfo.scope;
new SyncDailyLinks(this.ctrl)
.sync(doc, weekInfo.week, weekInfo.year, scopeId)
.catch(err => this.ctrl.logger.error("loadPageForInput: weekly sync failed:", err));
}
})
.catch(err => this.ctrl.logger.error("loadPageForInput: getWeekFromURIAndConfig failed:", err));
// Notify other features (e.g. weekly daily-link sync) without importing them.
this.ctrl.events.fireEntryOpened({ doc });
return doc;
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
'use strict';

import * as vscode from 'vscode';
import { JournalController, Input } from '../model';
import { JournalController, Input } from '../../../shared/model/index';
import { AbstractLoadEntryForDateCommand } from './show-entry-for-date';


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
'use strict';

import * as vscode from 'vscode';
import { JournalController, Input } from '../model';
import { JournalController, Input } from '../../../shared/model/index';
import { AbstractLoadEntryForDateCommand } from './show-entry-for-date';


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
'use strict';

import * as vscode from 'vscode';
import { JournalController, Input } from '../model';
import { JournalController, Input } from '../../../shared/model/index';
import { AbstractLoadEntryForDateCommand } from './show-entry-for-date';


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
'use strict';

import * as vscode from 'vscode';
import { JournalController, Input } from '../model';
import { JournalController, Input } from '../../../shared/model/index';
import { AbstractLoadEntryForDateCommand } from './show-entry-for-date';


Expand Down
3 changes: 0 additions & 3 deletions src/features/entries/index.ts

This file was deleted.

4 changes: 2 additions & 2 deletions src/journal/inject.ts → src/features/entries/inject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@


import * as vscode from 'vscode';
import { IConfiguration, ILogger, Input, InlineTemplate, InlineString, HeaderTemplate } from '../model';
import { isNullOrUndefined } from '../util';
import { IConfiguration, ILogger, Input, InlineTemplate, InlineString, HeaderTemplate } from '../../shared/model/index';
import { isNullOrUndefined } from '../../shared/index';



Expand Down
6 changes: 3 additions & 3 deletions src/journal/reader.ts → src/features/entries/reader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
'use strict';

import * as vscode from 'vscode';
import { IConfiguration, IDialogues, IFileSystem, ILogger, IWriter, Input } from '../model';
import { isNullOrUndefined, fileExists } from '../util';
import { resolvePath } from './paths';
import { IConfiguration, IDialogues, IFileSystem, ILogger, IWriter, Input } from '../../shared/model/index';
import { isNullOrUndefined, fileExists } from '../../shared/index';
import { resolvePath } from '../../shared/paths';

export class Reader {
public onNotesInjected?: (doc: vscode.TextDocument, date: Date) => void;
Expand Down
6 changes: 3 additions & 3 deletions src/features/entries/scan-entries.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as vscode from 'vscode';
import { inferType } from '../../journal';
import { FileEntry, IConfiguration, IFileSystem, ILogger, Input, JFileType, JournalPageType, ScopeDirectory } from '../../model';
import { inferType } from '../../shared/paths';
import { FileEntry, IConfiguration, IFileSystem, ILogger, Input, JFileType, JournalPageType, ScopeDirectory } from '../../shared/model/index';
import * as Path from 'path';
import { SCOPE_DEFAULT } from '../../vscode';
import { SCOPE_DEFAULT } from '../../shared/config/configuration';

export interface DecoratedQuickPickItem extends vscode.QuickPickItem {
parsedInput?: Input;
Expand Down
2 changes: 1 addition & 1 deletion src/journal/writer.ts → src/features/entries/writer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
'use strict';

import * as vscode from 'vscode';
import { DocumentOpener, IConfiguration, IFileSystem, IInject, ILogger } from '../model';
import { DocumentOpener, IConfiguration, IFileSystem, IInject, ILogger } from '../../shared/model/index';

/**
* Anything which modifies the text documents goes here.
Expand Down
2 changes: 0 additions & 2 deletions src/features/index.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
'use strict';

import * as vscode from 'vscode';
import { JournalController, Input } from '../model';
import { AbstractLoadEntryForDateCommand } from './show-entry-for-date';
import { daysBetween, findAdjacentEntry, getAdjacentWeekInput, resolveAnchor, Mode } from '../journal/navigation';
import { JournalController, Input } from '../../../shared/model/index';
import { AbstractLoadEntryForDateCommand } from '../../entries/commands/show-entry-for-date';
import { daysBetween, findAdjacentEntry, getAdjacentWeekInput, resolveAnchor, Mode } from '../navigation';

export class OpenNextEntryCommand extends AbstractLoadEntryForDateCommand {
title: string = "Open the next journal entry";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
'use strict';

import * as vscode from 'vscode';
import { JournalController, Input } from '../model';
import { AbstractLoadEntryForDateCommand } from './show-entry-for-date';
import { daysBetween, findAdjacentEntry, getAdjacentWeekInput, resolveAnchor, Mode } from '../journal/navigation';
import { JournalController, Input } from '../../../shared/model/index';
import { AbstractLoadEntryForDateCommand } from '../../entries/commands/show-entry-for-date';
import { daysBetween, findAdjacentEntry, getAdjacentWeekInput, resolveAnchor, Mode } from '../navigation';

export class OpenPreviousEntryCommand extends AbstractLoadEntryForDateCommand {
title: string = "Open the previous journal entry";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@

import * as vscode from 'vscode';
import * as Path from 'path';
import { SCOPE_DEFAULT, ScopeDefinitionLite } from '../vscode/conf';
import { getDateFromURIAndConfig, getWeekFromURIAndConfig } from './paths';
import { JournalController, Input } from '../model';
import { SCOPE_DEFAULT, ScopeDefinitionLite } from '../../shared/config/configuration';
import { getDateFromURIAndConfig, getWeekFromURIAndConfig } from '../../shared/paths';
import { JournalController, Input } from '../../shared/model/index';
import moment = require("moment");

/** Direction of entry navigation — step backward or forward relative to the anchor. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
'use strict';

import * as vscode from 'vscode';
import { LoadNotes } from '../features';
import { JournalController, Input, NoteInput } from '../model';
import { LoadNotes } from '../load-note';
import { JournalController, Input, NoteInput } from '../../../shared/model/index';


export class ShowNoteCommand implements vscode.Command, vscode.Disposable {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as vscode from 'vscode';
import { JournalController, Input, NoteInput } from '../../model';
import { fileExists } from '../../util';
import { JournalController, Input, NoteInput } from '../../shared/model/index';
import { fileExists } from '../../shared/index';

/**
* Feature responsible for creating (if needed) and loading notes given a user input as title.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as vscode from 'vscode';
import { JournalController, InlineString } from '../../model';
import { isNullOrUndefined } from '../../util';
import { JournalController, InlineString } from '../../shared/model/index';
import { isNullOrUndefined } from '../../shared/index';
import * as Path from 'path';


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@

import * as vscode from 'vscode';
import * as Path from 'path';
import { isNotNullOrUndefined, isString, isError, stringIsNotEmpty, denormalizeFilename } from '../util';
import { SCOPE_DEFAULT } from './conf';
import { isNotNullOrUndefined, isString, isError, stringIsNotEmpty, denormalizeFilename } from '../../shared/index';
import { SCOPE_DEFAULT } from '../../shared/config/configuration';
import moment = require('moment');
import { IConfiguration, IFileSystem, ILogger, IParser, JournalPageType, Input, ScopeDirectory, NoteInput, SelectedInput, FileEntry } from '../model';
import { sortPickEntries, ScanEntries, TimedQuickPick, DecoratedQuickPickItem } from '../features/entries/scan-entries';
import { IConfiguration, IFileSystem, ILogger, IParser, JournalPageType, Input, ScopeDirectory, NoteInput, SelectedInput, FileEntry } from '../../shared/model/index';
import { sortPickEntries, ScanEntries, TimedQuickPick, DecoratedQuickPickItem } from '../entries/scan-entries';



Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Logger } from "../util/logger";
import { isNullOrUndefined, isNotNullOrUndefined, getDayOfWeekForString } from "../util/";
import { Input, ParseConfidence } from "../model/input";
import { getMonthForString, getCurrentISOWeek } from "../util/dates";
import { Logger } from '../../shared/logging/logger';
import { isNullOrUndefined, isNotNullOrUndefined, getDayOfWeekForString } from '../../shared';
import { Input, ParseConfidence } from '../../shared/model/input';
import { getMonthForString, getCurrentISOWeek } from '../../shared/dates/dates';

export type EntryGranularity = "daily" | "weekly";

Expand Down
6 changes: 3 additions & 3 deletions src/journal/parser.ts → src/features/smart-input/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
'use strict';

import * as Path from 'path';
import { IConfiguration, ILogger, Input } from '../model';
import { normalizeFilename, getCurrentISOWeek, getISOWeekYear } from '../util';
import { MatchInput } from './match-input';
import { IConfiguration, ILogger, Input } from '../../shared/model/index';
import { normalizeFilename, getCurrentISOWeek, getISOWeekYear } from '../../shared/index';
import { MatchInput } from './match-input';

/**
* Helper Methods to interpret the input strings
Expand Down
2 changes: 0 additions & 2 deletions src/features/sync/index.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
'use strict';

import * as vscode from 'vscode';
import { JournalController } from '../../model';
import { JournalController } from '../../../shared/model/index';


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

import moment = require('moment');
import * as vscode from 'vscode';
import { JournalController, InlineTemplate } from '../../model';
import { ShiftTarget } from '../../commands/copy-task';
import { JournalController, InlineTemplate } from '../../../shared/model/index';
import { ShiftTarget } from '../commands/copy-task';


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
'use strict';

import * as vscode from 'vscode';
import { JournalController } from '../../model';
import { JournalController } from '../../../shared/model/index';


/**
Expand Down
Loading
Loading