[#763] v_summary.js: ensure getFiltered() is only called once when reloading page#800
Conversation
… watcher updates are done
fzdy1914
left a comment
There was a problem hiding this comment.
I am wondering how can you judge how many times getFiltered is called?
|
@fzdy1914 The number of modified toolbar controls. (Modified as in not the same as the default value) By default, the watcher for tmpFilterSinceDate and tmpFilterUntilDate will be called as their default values are empty strings ‘ ‘. So if the user changes group by to ‘groupByAuthors’ and granularity to ‘week’ (both are different compared to their default values), getFiltered will be called 5 times. (1 time for created() hook in v_summary, 2 times for tmpFilterSinceDate and tmpFilterUntilDate, and another 2 times for group by and granularity) |
fzdy1914
left a comment
There was a problem hiding this comment.
LGTM, I have tested, it indeed reduce the filter times from 3 to 1.
| this.getFiltered(); | ||
| if (this.isWatcherUpdated) { | ||
| this.getFiltered(); | ||
| } |
There was a problem hiding this comment.
Should this be method with a descriptive name?
There was a problem hiding this comment.
Yes I think it would be better to make this as a method.
| }, | ||
| getFilteredAfterWatcherUpdated() { | ||
| if (this.isWatcherUpdated) { | ||
| this.getFiltered(); |
There was a problem hiding this comment.
instead of doing this, why not just return in getFiltered if this.isWatcherUpdated is false instead?
It doesn't really quite make sense to name the method getFilteredAfterWatcherUpdated if all has to check for isWatcherUpdated
…ltered() (reposense#800)" This reverts commit f652054.
…800)" (#832) PR #800 was intended to ensure the getFiltered() method to be executed only once when the page is reloaded. The solution used was to set boolean canGetFiltered to true in beforeUpdate() lifecycle hook, preventing the execution of getFiltered() before the lifecycle hook. However, the beforeUpdate() lifecycle hook will only be executed when there are changes to the DOM. Instances where the page is reloaded and there are no changes to the DOM will not set boolean canGetFiltered to true, preventing getFiltered() to be executed until the DOM has changed. Let's revert PR #800 to allow getFiltered() to be executed even when there are no changes to the DOM.
Fixes #763