From 02ca0b56d7c64004d915d342e8ec002c5f50e1c0 Mon Sep 17 00:00:00 2001 From: joshuakto <34743132+joshuakto@users.noreply.github.com> Date: Thu, 7 Mar 2024 10:29:50 +0800 Subject: [PATCH 1/3] updated based on PR comments --- main.ts | 35 ++++++++++++----------------------- manifest.json | 2 +- src/fitSetting.ts | 12 ++++++------ versions.json | 14 +++++++------- 4 files changed, 26 insertions(+), 37 deletions(-) diff --git a/main.ts b/main.ts index 0e0e5c9..64e78fc 100644 --- a/main.ts +++ b/main.ts @@ -1,4 +1,4 @@ -import { Notice, Platform, Plugin, base64ToArrayBuffer } from 'obsidian'; +import { Notice, Plugin, base64ToArrayBuffer } from 'obsidian'; import { ComputeFileLocalShaModal, DebugModal } from 'src/pluginModal'; import { Fit } from 'src/fit'; import { FitPull } from 'src/fitPull'; @@ -16,22 +16,14 @@ export interface FitSettings { } const DEFAULT_SETTINGS: FitSettings = { - pat: "", - owner: "", - repo: "", - branch: "main", + pat: "", + owner: "", + repo: "", + branch: "", deviceName: "", - singleButtonMode: false + singleButtonMode: true } -const DEFAULT_MOBILE_SETTINGS: FitSettings = { - pat: "", - owner: "", - repo: "", - branch: "main", - deviceName: "", - singleButtonMode: false -} export interface LocalStores { localSha: Record @@ -63,15 +55,15 @@ export default class FitPlugin extends Plugin { checkSettingsConfigured(): boolean { - if ([" ", ""].includes(this.settings.pat)) { + if (this.settings.pat === "") { new Notice("Please provide git personal access tokens in Fit settings and try again.") return false } - if (["", ""].includes(this.settings.owner)) { + if (this.settings.owner === "") { new Notice("Please provide git repo owner in Fit settings and try again.") return false } - if (["", ""].includes(this.settings.repo)) { + if (this.settings.repo === "") { this.settings.repo = `obsidian-${this.app.vault.getName()}-storage` } this.fit.loadSettings(this.settings) @@ -276,7 +268,7 @@ export default class FitPlugin extends Plugin { async onload() { - await this.loadSettings(Platform.isMobile); + await this.loadSettings(); await this.loadLocalStore(); this.fit = new Fit(this.settings, this.localStore, this.app.vault) this.vaultOps = new VaultOperations(this.app.vault) @@ -358,12 +350,9 @@ export default class FitPlugin extends Plugin { onunload() {} - async loadSettings(isMobile?: boolean) { + async loadSettings() { const userSetting = await this.loadData() - let settings = Object.assign({}, DEFAULT_SETTINGS, userSetting); - if (isMobile && !userSetting) { - settings = Object.assign({}, DEFAULT_MOBILE_SETTINGS); - } + const settings = Object.assign({}, DEFAULT_SETTINGS, userSetting); const settingsObj: FitSettings = Object.keys(DEFAULT_SETTINGS).reduce( (obj, key: keyof FitSettings) => { if (settings.hasOwnProperty(key)) { diff --git a/manifest.json b/manifest.json index dc6acbb..a7ef463 100644 --- a/manifest.json +++ b/manifest.json @@ -2,7 +2,7 @@ "id": "fit", "name": "Fit", "version": "1.0.6", - "minAppVersion": "0.15.0", + "minAppVersion": "1.5.8", "description": "File gIT - a barebone git system for files in obsidian", "author": "joshuakto", "authorUrl": "https://github.com/joshuakto", diff --git a/src/fitSetting.ts b/src/fitSetting.ts index 1d288ff..ecc6a97 100644 --- a/src/fitSetting.ts +++ b/src/fitSetting.ts @@ -18,7 +18,7 @@ export default class FitSettingTab extends PluginSettingTab { .setName('Github personal access token') .setDesc('Remember to give it the appropriate access for reading and writing to the storage repo.') .addText(text => text - .setPlaceholder('Enter your token') + .setPlaceholder('GitHub personal access token') .setValue(this.plugin.settings.pat) .onChange(async (value) => { this.plugin.settings.pat = value; @@ -28,7 +28,7 @@ export default class FitSettingTab extends PluginSettingTab { .setName('Github username') .setDesc('Your github handle.') .addText(text => text - .setPlaceholder('Enter your username') + .setPlaceholder('GitHub username') .setValue(this.plugin.settings.owner) .onChange(async (value) => { this.plugin.settings.owner = value; @@ -38,7 +38,7 @@ export default class FitSettingTab extends PluginSettingTab { .setName('Github repository name') .setDesc('The repo you dedicate to tracking this vault.') .addText(text => text - .setPlaceholder('Enter your repository name') + .setPlaceholder('Repository') .setValue(this.plugin.settings.repo) .onChange(async (value) => { this.plugin.settings.repo = value; @@ -48,7 +48,7 @@ export default class FitSettingTab extends PluginSettingTab { .setName('Branch name') .setDesc('The branch name you set to push to (default to main)') .addText(text => text - .setPlaceholder('Enter the branch name') + .setPlaceholder('Branch name') .setValue(this.plugin.settings.branch) .onChange(async (value) => { this.plugin.settings.branch = value; @@ -59,7 +59,7 @@ export default class FitSettingTab extends PluginSettingTab { .setName('Device name') .setDesc('The name of this device, used to decorate commit message') .addText(text => text - .setPlaceholder('Enter device name') + .setPlaceholder('Device name') .setValue(this.plugin.settings.deviceName) .onChange(async (value) => { this.plugin.settings.deviceName = value; @@ -68,7 +68,7 @@ export default class FitSettingTab extends PluginSettingTab { new Setting(containerEl) .setName('Single button mode') - .setDesc('Single button mode is in early alpha, (recommended to turn off and push and pull separately).') + .setDesc('Single button to sync your repo to github (In early alpha, please file an issue if you encounter error with steps to reproduce).') .addToggle(selected=>selected .setValue(this.plugin.settings.singleButtonMode) .onChange(async (selected) => { diff --git a/versions.json b/versions.json index a1f309f..fc71916 100644 --- a/versions.json +++ b/versions.json @@ -1,9 +1,9 @@ { - "1.0.0": "0.15.0", - "1.0.1": "0.15.0", - "1.0.2": "0.15.0", - "1.0.3": "0.15.0", - "1.0.4": "0.15.0", - "1.0.5": "0.15.0", - "1.0.6": "0.15.0" + "1.0.0": "1.5.8", + "1.0.1": "1.5.8", + "1.0.2": "1.5.8", + "1.0.3": "1.5.8", + "1.0.4": "1.5.8", + "1.0.5": "1.5.8", + "1.0.6": "1.5.8" } \ No newline at end of file From cdc8d818c6a8d8f749aff1ec40490cc136ad0443 Mon Sep 17 00:00:00 2001 From: joshuakto <34743132+joshuakto@users.noreply.github.com> Date: Thu, 7 Mar 2024 10:44:48 +0800 Subject: [PATCH 2/3] added notice to let user know remote have changed --- main.ts | 11 +++++++---- styles.css | 21 ++++++++++++++++++++- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/main.ts b/main.ts index 64e78fc..180bf9c 100644 --- a/main.ts +++ b/main.ts @@ -198,10 +198,10 @@ export default class FitPlugin extends Plugin { return } - initializeFitNotice(): Notice { + initializeFitNotice(addClasses = ["loading"]): Notice { const notice = new Notice(" ", 0) // keep at least one empty space to make the height consistent - notice.noticeEl.addClass("fit-notice") - notice.noticeEl.addClass("loading") + notice.noticeEl.addClass("fit-notice") + addClasses.map(cls => notice.noticeEl.addClass(cls)) return notice } @@ -340,12 +340,15 @@ export default class FitPlugin extends Plugin { if (this.checkSettingsConfigured()) { const updatedRemoteCommitSha = await this.fitPull.remoteHasUpdates() if (updatedRemoteCommitSha) { + const intervalNotice = this.initializeFitNotice(["static"]); + intervalNotice.setMessage("Remote update detected, please pull the latest changes.") + // new Notice("Remote update detected, please pull the latest changes.") console.log(`Remote updated, latest remote commit sha: ${updatedRemoteCommitSha}.`) } else { console.log(`Local copy up to date.`) } } - }, 5 * 60 * 1000)); + }, 10 * 1000)); } onunload() {} diff --git a/styles.css b/styles.css index 7d9c1c6..acb424f 100644 --- a/styles.css +++ b/styles.css @@ -4,6 +4,16 @@ overflow: hidden; } +.fit-notice.static::after { + content: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9IiM5NDk0OTQiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIiBjbGFzcz0ibHVjaWRlIGx1Y2lkZS1naXRodWIiPjxwYXRoIGQ9Ik0xNSAyMnYtNGE0LjggNC44IDAgMCAwLTEtMy41YzMgMCA2LTIgNi01LjUuMDgtMS4yNS0uMjctMi40OC0xLTMuNS4yOC0xLjE1LjI4LTIuMzUgMC0zLjUgMCAwLTEgMC0zIDEuNS0yLjY0LS41LTUuMzYtLjUtOCAwQzYgMiA1IDIgNSAyYy0uMyAxLjE1LS4zIDIuMzUgMCAzLjVBNS40MDMgNS40MDMgMCAwIDAgNCA5YzAgMy41IDMgNS41IDYgNS41LS4zOS40OS0uNjggMS4wNS0uODUgMS42NS0uMTcuNi0uMjIgMS4yMy0uMTUgMS44NXY0Ii8+PHBhdGggZD0iTTkgMThjLTQuNTEgMi01LTItNy0yIi8+PC9zdmc+"); /* Add content to pseudo-element */ + position: absolute; /* Set position to absolute */ + width: 24px; /* Set width of the pseudo-element */ + height: 24px; /* Set height of the pseudo-element */ + top: 47%; /* Position at the center vertically */ + left: 5.7%; /* Position at the center horizontally */ + transform: translate(-50%, -50%); /* Center the pseudo-element */ +} + .fit-notice.loading::after { content: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9IiM5NDk0OTQiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIiBjbGFzcz0ibHVjaWRlIGx1Y2lkZS1naXRodWIiPjxwYXRoIGQ9Ik0xNSAyMnYtNGE0LjggNC44IDAgMCAwLTEtMy41YzMgMCA2LTIgNi01LjUuMDgtMS4yNS0uMjctMi40OC0xLTMuNS4yOC0xLjE1LjI4LTIuMzUgMC0zLjUgMCAwLTEgMC0zIDEuNS0yLjY0LS41LTUuMzYtLjUtOCAwQzYgMiA1IDIgNSAyYy0uMyAxLjE1LS4zIDIuMzUgMCAzLjVBNS40MDMgNS40MDMgMCAwIDAgNCA5YzAgMy41IDMgNS41IDYgNS41LS4zOS40OS0uNjggMS4wNS0uODUgMS42NS0uMTcuNi0uMjIgMS4yMy0uMTUgMS44NXY0Ii8+PHBhdGggZD0iTTkgMThjLTQuNTEgMi01LTItNy0yIi8+PC9zdmc+"); /* Add content to pseudo-element */ position: absolute; /* Set position to absolute */ @@ -12,7 +22,16 @@ top: 15%; /* Position at the center vertically */ left: 2%; /* Position at the center horizontally */ transform: translate(-50%, -50%); /* Center the pseudo-element */ - animation: spin 2s linear infinite; /* Apply spinning animation to the icon */ + animation: spin-notice 2s linear infinite; /* Apply spinning animation to the icon */ +} + +@keyframes spin-notice { + from { + transform: rotate(0deg); + } + to { + transform: rotate(360deg); + } } .fit-notice.done::after { From 7ba08670e1922a36aa870d624f41d8287e3a68f9 Mon Sep 17 00:00:00 2001 From: joshuakto <34743132+joshuakto@users.noreply.github.com> Date: Thu, 7 Mar 2024 10:46:11 +0800 Subject: [PATCH 3/3] updated manifest.json --- manifest.json | 4 ++-- versions.json | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/manifest.json b/manifest.json index a7ef463..734affb 100644 --- a/manifest.json +++ b/manifest.json @@ -1,9 +1,9 @@ { "id": "fit", "name": "Fit", - "version": "1.0.6", + "version": "1.0.7", "minAppVersion": "1.5.8", - "description": "File gIT - a barebone git system for files in obsidian", + "description": "Minimalist File gIT (FIT) to sync your files across mobile and desktop devices using GitHub.", "author": "joshuakto", "authorUrl": "https://github.com/joshuakto", "fundingUrl": "https://www.buymeacoffee.com/joshuakto", diff --git a/versions.json b/versions.json index fc71916..87d3ecb 100644 --- a/versions.json +++ b/versions.json @@ -5,5 +5,6 @@ "1.0.3": "1.5.8", "1.0.4": "1.5.8", "1.0.5": "1.5.8", - "1.0.6": "1.5.8" + "1.0.6": "1.5.8", + "1.0.7": "1.5.8" } \ No newline at end of file