Various AT Protocol integrations with obsidian

open clipped document if already exists (#8)

* handle existing clipped document

* bump version

authored by

treethought and committed by
GitHub
2fca9b3c b4c8247e

+18 -3
+1 -1
manifest.json
··· 1 1 { 2 2 "id": "atmosphere", 3 3 "name": "Atmosphere", 4 - "version": "0.1.10", 4 + "version": "0.1.11", 5 5 "minAppVersion": "0.15.0", 6 6 "description": "Various integrations with AT Protocol.", 7 7 "author": "treethought",
+1 -1
package.json
··· 1 1 { 2 2 "name": "obsidian-atmosphere", 3 - "version": "0.1.10", 3 + "version": "0.1.11", 4 4 "description": "Various integrations with AT Protocol.", 5 5 "main": "main.js", 6 6 "type": "module",
+8
src/lib/clipper.ts
··· 80 80 } 81 81 const filePath = this.safeFilePath(doc.value.title, clipDir); 82 82 83 + const existingFile = vault.getAbstractFileByPath(filePath); 84 + if (existingFile && existingFile instanceof TFile) { 85 + const leaf = this.plugin.app.workspace.getLeaf(false); 86 + await leaf.openFile(existingFile); 87 + new Notice(`Opened existing clipped document: ${filePath}`); 88 + return; 89 + } 90 + 83 91 let content = `# ${doc.value.title}\n\n`; 84 92 85 93 if (doc.value.description) {
+8 -1
src/views/standardfeed.ts
··· 185 185 header.createEl("h3", { text: doc.value.title, cls: "standard-site-document-title" }); 186 186 187 187 let clipIcon = "book-open"; 188 - if (this.plugin.clipper.existsInClipDir(doc)) { 188 + const isClipped = this.plugin.clipper.existsInClipDir(doc); 189 + if (isClipped) { 189 190 clipIcon = "book-open-check"; 190 191 } 191 192 const clipBtn = header.createEl("span", { cls: "clickable standard-site-document-clip" }); 193 + if (isClipped) { 194 + clipBtn.addClass("mod-success"); 195 + clipBtn.setAttribute("aria-label", "Already clipped"); 196 + } else { 197 + clipBtn.setAttribute("aria-label", "Clip document"); 198 + } 192 199 setIcon(clipBtn, clipIcon); 193 200 clipBtn.addEventListener("click", (e) => { 194 201 e.stopPropagation();