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

Expose NSFW to inheritors of NsfwFilesystemWatcher #7465

Merged
merged 1 commit into from
Jun 5, 2020

Conversation

mcgordonite
Copy link
Contributor

@mcgordonite mcgordonite commented Mar 31, 2020

What it does

This PR adds a protected method to NsfwFileSystemWatcherServer a new service identifier NsfwOptions that allows extensions to specify options to pass to nsfw.

For example, this enables extensions to specify the debounceMS setting for file watchers.

How to test

To test that the options are sent to nsfw, you could:

  1. Rebind NsfwOptions to { debouncMS: 10000 } in a backend extension.
  2. Build the extension package and browser example app.
  3. Start the browser example app.
  4. Try to add multiple files to the workspace in quick succession. Verify that there is a visible debounce in updating the file navigator.

Review checklist

Reminder for reviewers

@vince-fugnitto vince-fugnitto added the filesystem issues related to the filesystem label Apr 1, 2020
Copy link
Member

@paul-marechal paul-marechal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is a minimal modification, but would it be easier to return the complete option object from this new method? Extenders would have to return something like:

    protected getNsfwOptions(watcherId: number, basePath: string, options: WatchOptions): nsfw.Options {
        return Object.assign(super.getNsfwOptions(watcherId, basePath, options), {
            // ...
        });
    }

WDYT?

@akosyakov
Copy link
Member

akosyakov commented Apr 2, 2020

I wonder how it can be extended, we run nsfw watching in separate process without DI to avoid blocking the server process.

Added an inversify service identifier so extensions can customise the
options passed to NSFW.

Signed-off-by: Matthew Gordon <matthew.gordon@arm.com>
@mcgordonite
Copy link
Contributor Author

@akosyakov and @marechal-p, sorry for the delay getting back to you.

@akosyakov was right, it was hard to override the file watcher server correctly. Extenders would have had to overwrite the nsfw-watcher sub-processes entry script as well.

Instead, I've updated this PR to add an NsfwOptions service identifier, so other extensions can rebind their new options:

rebind(NsfwOptions).toConstantValue({
    debounceMS: 5000
});

For full disclosure, we have forked nsfw to add some application-specific behaviour that is controlled by a new flag in nsfw.Options.

Copy link
Member

@akosyakov akosyakov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code looks clean, watching still works

@akosyakov akosyakov merged commit 74b20d3 into eclipse-theia:master Jun 5, 2020
@mcgordonite mcgordonite deleted the nsfw-options branch June 5, 2020 08:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
filesystem issues related to the filesystem
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants