Open w-4 opened 3 years ago
Can be done probably when converting these files to TypeScript.
Not entirely sure, but I think some of these actions are referenced from other files. The import statement would change and thus would be a breaking change.
Because right now we have the import UserControls from '...'
, that'd have to be changed to import * as UserControls from '...'
I think.
I do agree that we don't want to bind this
.
My biggest concern with this approach is that the extend
and override
utils wouldn't work on standalone functions.
That's true, we'd need to also export it as an object in addition. That's also needed for the extensions public API, so that webpack uglify does not alter the names.
export default DiscussionControls = {
userControls,
moderationControls,
destructiveControls,
...
};
It doesn't matter what uglify does, as the "public API" comes from the compat
files, where we use strings and so they aren't affected by uglify. Extensibility is an issue that could maybe be solved with that method, however.
We should also consider some of the options discussed in https://github.com/flarum/core/issues/1317
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. We do this to keep the amount of open issues to a manageable minimum. In any case, thanks for taking an interest in this software and contributing by opening the issue in the first place!
Feature Request
Here's a screenshot of the before (left) and after:
The biggest benefit is that when calling the function one doesn't have to use
.call(discussion)
anymore and the code becomes more readable. Another benefit is that you can call one utils function from another in the same file, which was previously impractical, sincethis
was already bound to the discussion.Applies to
PostControls
,DiscussionControls
,UserControls
. Can be done probably when converting these files to TypeScript.