Skip to content

Commit a50ed57

Browse files
committed
fix(history): Fix history file filter.
1 parent 41b1c6e commit a50ed57

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

src/main.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -187,25 +187,28 @@ export default class InvioPlugin extends Plugin {
187187
async getLocalFileStatus() {
188188
const isWatched = (p: string) => {
189189
const pF = new Path(p)
190-
pF.isInsideDir(this.settings.localWatchDir) &&
191-
!pF.isInsideDir(RemoteConflictPrefix) &&
192-
!pF.isInsideDir(LocalConflictPrefix) &&
190+
if (p.endsWith('/')) {
191+
return pF.isInsideDir(this.settings.localWatchDir) &&
192+
!pF.isInsideDir(this.settings.localWatchDir + '/' + RemoteConflictPrefix) &&
193+
!pF.isInsideDir(this.settings.localWatchDir + '/' + LocalConflictPrefix) &&
194+
!(pF.asString === (this.settings.localWatchDir + '/' + RemoteConflictPrefix)) &&
195+
!(pF.asString === (this.settings.localWatchDir + '/' + LocalConflictPrefix))
196+
}
197+
return pF.isInsideDir(this.settings.localWatchDir) &&
198+
!pF.isInsideDir(this.settings.localWatchDir + '/' + RemoteConflictPrefix) &&
199+
!pF.isInsideDir(this.settings.localWatchDir + '/' + LocalConflictPrefix) &&
193200
!p.endsWith('.conflict.md')
194201
}
195202
// this.app.vault.getAllLoadedFiles
196203
// TODO: List only concerned files, only source of truth
197204
// *.conflict.md files is for data backup when conflicts happened
198-
const local = this.app.vault.getMarkdownFiles().filter(file => {
199-
return isWatched(file.path)
200-
});
205+
const local = this.app.vault.getMarkdownFiles().filter(file => isWatched(file.path));
201206
log.info('local file path list: ', local);
202207
// const local = this.app.vault.getAllLoadedFiles();
203208
const localHistory = (await loadFileHistoryTableByVault(
204209
this.db,
205210
this.vaultRandomID
206-
)).filter(item => {
207-
return isWatched(item.key)
208-
})
211+
)).filter(item => isWatched(item.key))
209212
let localConfigDirContents: ObsConfigDirFileType[] = undefined;
210213
if (this.settings.syncConfigDir) {
211214
localConfigDirContents = await listFilesInObsFolder(

0 commit comments

Comments
 (0)