mirror of
https://github.com/zoorpha/rustshare-obsidian-plugin.git
synced 2026-07-22 07:48:14 +00:00
Fix settings headings and remove hardcoded .obsidian parameter default
This commit is contained in:
parent
dabe5123c7
commit
bf03a0fc8b
4 changed files with 23 additions and 23 deletions
11
src/main.ts
11
src/main.ts
|
|
@ -92,30 +92,29 @@ export default class RustShareVaultSyncPlugin extends Plugin {
|
|||
this.startAutoSync();
|
||||
}
|
||||
|
||||
// File event listeners
|
||||
this.registerEvent(this.app.vault.on('create', (file) => {
|
||||
if (file instanceof TFile && !shouldIgnorePath(file.path)) {
|
||||
if (file instanceof TFile && !shouldIgnorePath(file.path, this.app.vault.configDir)) {
|
||||
syncLog.debug('Event: create', file.path);
|
||||
this.syncQueue.add({ path: file.path, type: 'create' });
|
||||
}
|
||||
}));
|
||||
|
||||
this.registerEvent(this.app.vault.on('delete', (file) => {
|
||||
if (file instanceof TFile && !shouldIgnorePath(file.path)) {
|
||||
if (file instanceof TFile && !shouldIgnorePath(file.path, this.app.vault.configDir)) {
|
||||
syncLog.debug('Event: delete', file.path);
|
||||
this.syncQueue.add({ path: file.path, type: 'delete' });
|
||||
}
|
||||
}));
|
||||
|
||||
this.registerEvent(this.app.vault.on('rename', (file, oldPath) => {
|
||||
if (file instanceof TFile && !shouldIgnorePath(file.path)) {
|
||||
if (file instanceof TFile && !shouldIgnorePath(file.path, this.app.vault.configDir)) {
|
||||
syncLog.debug('Event: rename', `${oldPath} -> ${file.path}`);
|
||||
this.syncQueue.add({ path: file.path, type: 'rename', oldPath });
|
||||
}
|
||||
}));
|
||||
|
||||
this.registerEvent(this.app.vault.on('modify', (file) => {
|
||||
if (file instanceof TFile && !shouldIgnorePath(file.path)) {
|
||||
if (file instanceof TFile && !shouldIgnorePath(file.path, this.app.vault.configDir)) {
|
||||
syncLog.debug('Event: modify', file.path);
|
||||
this.syncQueue.add({ path: file.path, type: 'modify' });
|
||||
}
|
||||
|
|
@ -194,7 +193,7 @@ export default class RustShareVaultSyncPlugin extends Plugin {
|
|||
const maxWaitMs = pairing.expires_in * 1000;
|
||||
|
||||
while (Date.now() - startTime < maxWaitMs) {
|
||||
await new Promise(resolve => setTimeout(resolve, 3000));
|
||||
await new Promise(resolve => window.setTimeout(resolve, 3000));
|
||||
|
||||
const poll = await api.pollDevicePairing(pairing.device_code);
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ export class RustShareVaultSyncSettingTab extends PluginSettingTab {
|
|||
containerEl.empty();
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('RustShare Vault Sync Settings')
|
||||
.setName('Vault connection')
|
||||
.setHeading();
|
||||
|
||||
// Disclaimer
|
||||
|
|
@ -74,7 +74,7 @@ export class RustShareVaultSyncSettingTab extends PluginSettingTab {
|
|||
}));
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('Advanced Sync Settings')
|
||||
.setName('Advanced')
|
||||
.setHeading();
|
||||
|
||||
new Setting(containerEl)
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ export function formatConflictFileName(originalPath: string, deviceName: string,
|
|||
return `${dir}${name} (RustShare conflicted copy ${safeDeviceName} ${timestamp})${ext}`;
|
||||
}
|
||||
|
||||
export function shouldIgnorePath(path: string, configDir = '.obsidian'): boolean {
|
||||
export function shouldIgnorePath(path: string, configDir: string): boolean {
|
||||
const normalizedConfigDir = configDir.endsWith('/') ? configDir : configDir + '/';
|
||||
const ignoredPaths = [
|
||||
normalizedConfigDir,
|
||||
|
|
|
|||
|
|
@ -55,35 +55,36 @@ describe('formatConflictFileName', () => {
|
|||
});
|
||||
|
||||
describe('shouldIgnorePath', () => {
|
||||
it('returns true for .obsidian/', () => {
|
||||
expect(shouldIgnorePath('.obsidian/app.json')).toBe(true);
|
||||
expect(shouldIgnorePath('.obsidian/')).toBe(true);
|
||||
it('returns true for configDir/', () => {
|
||||
expect(shouldIgnorePath('.obsidian/app.json', '.obsidian')).toBe(true);
|
||||
expect(shouldIgnorePath('.obsidian/', '.obsidian')).toBe(true);
|
||||
expect(shouldIgnorePath('custom-config/app.json', 'custom-config')).toBe(true);
|
||||
});
|
||||
|
||||
it('returns true for .git/', () => {
|
||||
expect(shouldIgnorePath('.git/config')).toBe(true);
|
||||
expect(shouldIgnorePath('notes/.git/')).toBe(true);
|
||||
expect(shouldIgnorePath('.git/config', '.obsidian')).toBe(true);
|
||||
expect(shouldIgnorePath('notes/.git/', '.obsidian')).toBe(true);
|
||||
});
|
||||
|
||||
it('returns true for .DS_Store', () => {
|
||||
expect(shouldIgnorePath('.DS_Store')).toBe(true);
|
||||
expect(shouldIgnorePath('folder/.DS_Store')).toBe(true);
|
||||
expect(shouldIgnorePath('.DS_Store', '.obsidian')).toBe(true);
|
||||
expect(shouldIgnorePath('folder/.DS_Store', '.obsidian')).toBe(true);
|
||||
});
|
||||
|
||||
it('returns true for node_modules/', () => {
|
||||
expect(shouldIgnorePath('node_modules/')).toBe(true);
|
||||
expect(shouldIgnorePath('src/node_modules/pkg/')).toBe(true);
|
||||
expect(shouldIgnorePath('node_modules/', '.obsidian')).toBe(true);
|
||||
expect(shouldIgnorePath('src/node_modules/pkg/', '.obsidian')).toBe(true);
|
||||
});
|
||||
|
||||
it('returns true for Thumbs.db', () => {
|
||||
expect(shouldIgnorePath('Thumbs.db')).toBe(true);
|
||||
expect(shouldIgnorePath('images/Thumbs.db')).toBe(true);
|
||||
expect(shouldIgnorePath('Thumbs.db', '.obsidian')).toBe(true);
|
||||
expect(shouldIgnorePath('images/Thumbs.db', '.obsidian')).toBe(true);
|
||||
});
|
||||
|
||||
it('returns false for normal file paths', () => {
|
||||
expect(shouldIgnorePath('notes/hello.md')).toBe(false);
|
||||
expect(shouldIgnorePath('README.md')).toBe(false);
|
||||
expect(shouldIgnorePath('deep/nested/path/file.txt')).toBe(false);
|
||||
expect(shouldIgnorePath('notes/hello.md', '.obsidian')).toBe(false);
|
||||
expect(shouldIgnorePath('README.md', '.obsidian')).toBe(false);
|
||||
expect(shouldIgnorePath('deep/nested/path/file.txt', '.obsidian')).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue