Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scan selected folders instead of all #455

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

Huxzhi
Copy link

@Huxzhi Huxzhi commented Oct 27, 2023

Use selected files instand of app.vault.getMarkdownFiles()

main.ts 179
const manager = new FileManager(this.app, data, this.app.vault.getMarkdownFiles(), this.file_hashes, this.added_media)

    let folder_list = [];
    //  selected files from  plugin.settings.ScanFolder 
    for (let i of data.scan_folder) {
      folder_list.push(this.app.vault.fileMap[i]);
    }

    for (let folder of folder_list) {
      let filtered_list = folder.children.filter((element) =>
        element.hasOwnProperty("children")
      );
      folder_list.push(...filtered_list);
    }

    let scanFiles = [];
    for (let flie of folder_list) {
      let filtered_list = flie.children.filter(
        (element) =>
          element.hasOwnProperty("extension") && element.extension === "md"
      );
      scanFiles.push(...filtered_list);
    }

settings-tab selected files

Select a folder and prompt

add UI src/settings.ts 41-97

image

src/settings.ts 348

  get_folders(): TFolder[] {
    const app = (this as any).plugin.app;

    let folder_list: TFolder[] = [];

    for (let i of this.plugin.settings.ScanFolder) {
      folder_list.push(app.vault.fileMap[i]);
    }
    for (let folder of folder_list) {
      let filtered_list: TFolder[] = folder.children.filter((element) =>
        element.hasOwnProperty("children")
      ) as TFolder[];
      folder_list.push(...filtered_list);
    }
    return folder_list.slice(this.plugin.settings.ScanFolder.length); //Removes initial vault folder
  }

@mattcoleanderson
Copy link

There is an open PR for this change since 2021 here as well: #289

@ShootingKing-AM
Copy link
Member

Can you rebase this PR and add some Tests ? Do take note of this feature (ShootingKing-AM#154)

@ShootingKing-AM ShootingKing-AM marked this pull request as draft January 7, 2024 07:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants