Skip to content

Commit

Permalink
Merge pull request #7 from RyoJerryYu/feat-rename-class-name-for-plac…
Browse files Browse the repository at this point in the history
…eholder

feat: rename class name for placeholder
  • Loading branch information
RyoJerryYu authored May 27, 2024
2 parents 0686bcd + 530fe1b commit 4598109
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 28 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "obsidian-memos-sync",
"name": "Memos Sync",
"version": "0.3.1",
"version": "0.3.2",
"minAppVersion": "0.15.0",
"description": "Syncing memos from a [Memos](https://github.com/usememos/memos) server to Obsidian daily note. Fully compatible with official Daily Notes plugin, Calendar plugin and Periodic Notes plugin.",
"author": "RyoJerryYu",
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": "obsidian-memos-sync",
"version": "0.3.1",
"version": "0.3.2",
"description": "Syncing Memos to Obsidian daily note.",
"main": "main.js",
"scripts": {
Expand Down
34 changes: 17 additions & 17 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,37 @@ import {
import * as React from "react";
import { createRoot } from "react-dom/client";
import { DailyMemos } from "@/services/DailyMemos/DailyMemos";
import { PluginSettings } from "@/types/PluginSettings";
import { MemosSyncPluginSettings } from "@/types/PluginSettings";
import { appHasDailyNotesPluginLoaded } from "obsidian-daily-notes-interface";

// Remember to rename these classes and interfaces!

const DEFAULT_SETTINGS: PluginSettings = {
const MEMOS_SYNC_DEFAULT_SETTINGS: MemosSyncPluginSettings = {
dailyMemosHeader: "Memos",
memosAPIVersion: "v0.19.1",
memosAPIURL: "https://usememos.com",
memosAPIToken: "",
attachmentFolder: "Attachments",
};

export default class MyPlugin extends Plugin {
settings: PluginSettings;
export default class MemosSyncPlugin extends Plugin {
settings: MemosSyncPluginSettings;
dailyMemos: DailyMemos;

async onload() {
await this.loadSettings();
await this.loadDailyMemos();

// This adds a settings tab so the user can configure various aspects of the plugin
this.addSettingTab(new SampleSettingTab(this.app, this));
this.addSettingTab(new MemosSyncSettingTab(this.app, this));
}

onunload() {}

loadSettings = async () => {
this.settings = Object.assign(
{},
DEFAULT_SETTINGS,
MEMOS_SYNC_DEFAULT_SETTINGS,
await this.loadData()
);
};
Expand All @@ -56,17 +56,17 @@ export default class MyPlugin extends Plugin {
loadDailyMemos = async () => {
this.dailyMemos = new DailyMemos(this.app, this.settings);
this.addCommand({
id: "my-plugin-sync-daily-memos",
id: "obsidian-memos-sync-daily-memos",
name: "Sync daily memos",
callback: this.dailyMemos.sync,
});
this.addCommand({
id: "my-plugin-force-sync-daily-memos",
id: "obsidian-memos-force-sync-daily-memos",
name: "Force sync daily memos",
callback: this.dailyMemos.forceSync,
});
this.addCommand({
id: "my-plugin-force-sync-current-daily-memos",
id: "obsidian-memos-sync-force-current-daily-memos",
name: "Force sync current daily memos",
callback: this.dailyMemos.syncForCurrentFile,
});
Expand All @@ -77,16 +77,16 @@ export default class MyPlugin extends Plugin {
};
}

class SampleSettingTab extends PluginSettingTab {
class MemosSyncSettingTab extends PluginSettingTab {
app: App;
plugin: MyPlugin;
plugin: MemosSyncPlugin;

constructor(app: App, plugin: MyPlugin) {
constructor(app: App, plugin: MemosSyncPlugin) {
super(app, plugin);
this.plugin = plugin;
}

private saveSettings = (newSettings: Partial<PluginSettings>) => {
private saveSettings = (newSettings: Partial<MemosSyncPluginSettings>) => {
this.plugin.settings = {
...this.plugin.settings,
...newSettings,
Expand Down Expand Up @@ -119,7 +119,7 @@ class SampleSettingTab extends PluginSettingTab {
.setName("Daily Memos Header")
.setDesc("The header for the daily memos section.")
.addText((textfield) => {
textfield.setPlaceholder(DEFAULT_SETTINGS.dailyMemosHeader);
textfield.setPlaceholder(MEMOS_SYNC_DEFAULT_SETTINGS.dailyMemosHeader);
textfield.setValue(this.plugin.settings.dailyMemosHeader);
textfield.onChange((value) => {
this.saveSettings({
Expand All @@ -132,7 +132,7 @@ class SampleSettingTab extends PluginSettingTab {
.setName("Attachment Folder")
.setDesc("The folder for attachments.")
.addText((textfield) => {
textfield.setPlaceholder(DEFAULT_SETTINGS.attachmentFolder);
textfield.setPlaceholder(MEMOS_SYNC_DEFAULT_SETTINGS.attachmentFolder);
textfield.setValue(this.plugin.settings.attachmentFolder);
textfield.onChange((value) => {
this.saveSettings({
Expand Down Expand Up @@ -161,7 +161,7 @@ class SampleSettingTab extends PluginSettingTab {
.setName("Memos API URL")
.setDesc("Memos API URL, e.g. http://localhost:5230")
.addText((textfield) => {
textfield.setPlaceholder(DEFAULT_SETTINGS.memosAPIURL);
textfield.setPlaceholder(MEMOS_SYNC_DEFAULT_SETTINGS.memosAPIURL);
textfield.setValue(this.plugin.settings.memosAPIURL);
textfield.onChange((value) => {
this.saveSettings({
Expand All @@ -174,7 +174,7 @@ class SampleSettingTab extends PluginSettingTab {
.setName("Memos API Token")
.setDesc("Memos API token.")
.addText((textfield) => {
textfield.setPlaceholder(DEFAULT_SETTINGS.memosAPIToken);
textfield.setPlaceholder(MEMOS_SYNC_DEFAULT_SETTINGS.memosAPIToken);
textfield.setValue(this.plugin.settings.memosAPIToken);
textfield.onChange((value) => {
this.saveSettings({
Expand Down
6 changes: 3 additions & 3 deletions src/services/DailyMemos/DailyMemos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
} from "obsidian-daily-notes-interface";
import type { Moment } from "moment";
import { App, MarkdownView, TFile, normalizePath } from "obsidian";
import { PluginSettings } from "@/types/PluginSettings";
import { MemosSyncPluginSettings } from "@/types/PluginSettings";
import * as log from "@/utils/log";
import { MemosPaginator } from "./MemosPaginator";
import { DailyNoteModifier } from "./DailyNoteModifier";
Expand Down Expand Up @@ -39,13 +39,13 @@ class DailyNoteManager {

export class DailyMemos {
private app: App;
private settings: PluginSettings;
private settings: MemosSyncPluginSettings;
private localKey: string;
private memosFactory: MemosAbstractFactory;
private memosPaginator: MemosPaginator;
private memosResourceFetcher: MemosResourceFetcher;

constructor(app: App, settings: PluginSettings) {
constructor(app: App, settings: MemosSyncPluginSettings) {
if (!settings.memosAPIURL) {
log.error(
"Please set the usememosAPI setting in the plugin settings."
Expand Down
8 changes: 4 additions & 4 deletions src/services/DailyMemos/MemosVersionFactory.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PluginSettings } from "@/types/PluginSettings";
import { MemosSyncPluginSettings } from "@/types/PluginSettings";
import {
MemosPaginator,
MemosPaginator0191,
Expand All @@ -21,7 +21,7 @@ import {
export class MemosAbstractFactory {
private inner: MemosFactory;

constructor(private settings: PluginSettings) {
constructor(private settings: MemosSyncPluginSettings) {
if (this.settings.memosAPIVersion === "v0.22.0") {
const { memoCli, resourceCli } = newClients(
this.settings.memosAPIURL,
Expand Down Expand Up @@ -63,7 +63,7 @@ type MemosFactory = {

class MemosFactory0191 {
private client: MemosClient0191;
constructor(private settings: PluginSettings) {
constructor(private settings: MemosSyncPluginSettings) {
this.client = new MemosClient0191(
this.settings.memosAPIURL,
this.settings.memosAPIToken
Expand All @@ -88,7 +88,7 @@ class MemosFactory0191 {
class MemosFactory0220 {
private memoCli: MemoCli;
private resourceCli: ResourceCli;
constructor(private settings: PluginSettings) {
constructor(private settings: MemosSyncPluginSettings) {
const { memoCli, resourceCli } = newClients(
this.settings.memosAPIURL,
this.settings.memosAPIToken
Expand Down
2 changes: 1 addition & 1 deletion src/types/PluginSettings.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export interface PluginSettings {
export interface MemosSyncPluginSettings {
/**
* The header for the daily memos section.
*/
Expand Down
3 changes: 2 additions & 1 deletion versions.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"1.0.0": "0.15.0",
"0.3.0": "0.15.0",
"0.3.1": "0.15.0"
"0.3.1": "0.15.0",
"0.3.2": "0.15.0"
}

0 comments on commit 4598109

Please sign in to comment.