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

Fix opening a section again in the Files app #11967

Merged
merged 3 commits into from
Oct 23, 2018

Conversation

danxuliu
Copy link
Member

Fixes #11907

When a section is open in the Files app a show event is triggered. File list objects handle that event by reloading themselves, but only if the file list was shown at least once. This is needed to prevent a race condition when the Files app is initially loaded, as in that case the file list could be reloaded twice, one time due to the show event and another time due to a directory change when parsing the URL.

However, the file list objects of plugins are created when the show event is triggered for the first time for their section; as the file list objects register their handler for the show event when they are created they never handle the first triggered show event, as the handler is set while that event is being already handled. Therefore, from the point of view of the handler, the second time that a show event was triggered it was seen as if the file list was shown for the first time, and thus it was not reloaded. Now the shown property is explicitly set for those file lists that are created while handling a show event, which causes them to be reloaded as expected when opening their section again.

"But, wait, before this fix the file list for favorites and shares did not have the shown property set, yet they were reloaded without problems the second time that their section was opened, why?". Because they overrode the onUrlChanged method to change the directory; as the URL changes when a different section is opened (due to the trailing view=XXX part) the file list always got reloaded, although not necessarily due to the show event. The method was overrode for both favorites and shares to fix the file list not being reloaded when showing it again, so this pull request removes them as now that the shown property is explicitly set that fix is no longer needed.

In the case of the file list for system tags, however, the _onUrlChanged method was not removed as it was overrode for a different purpose (parsing the tags to search for from the URL). Note that opening again that section clears the tags to search for previously set, but that is a different issue than the one fixed here (and it is not too bad either, as searching for the tags again works without problems).

When a section is open in the Files app a "show" event is triggered.
File list objects handle that event by reloading themselves, but only
if the file list was shown at least once. However, the file list objects
of plugins are created when the "show" event is triggered for the first
time for their section; as the file list objects register their handler
for the "show" event when they are created they never handle the first
triggered "show" event, as the handler is set while that event is being
already handled. Therefore, from the point of view of the handler, the
second time that a "show" event was triggered it was seen as if the file
list was shown for the first time, and thus it was not reloaded. Now the
"shown" property is explicitly set for those file lists that are created
while handling a "show" event, which causes them to be reloaded as
expected when opening their section again.

Note that it is not possible to just reload the file list whenever it is
shown; the file list is reloaded also when the directory changes, and
this can happen when the web page is initially loaded and the URL is
parsed. In that case, if file lists were reloaded when shown for the
first time then it could be reloaded twice, one with the default
parameters due to the "show" event and another one with the proper
parameters once the URL was parsed, and the files that appeard in the
list would depend on which response from the server was received the
last.

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
The custom handler for "URL changed" events were added to reload the
file list whenever the sections for favorites and shares were opened;
this was used to fix the problem of not reloading the file lists when
opening them for a second time. However, besides that the handlers were
not really necessary, and as the root of the bug was fixed in the
previous commit those handlers are now removed.

The file list for tags uses the handler for a different purpose, though,
so that one was kept.

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
@rullzer
Copy link
Member

rullzer commented Oct 21, 2018

Add acceptance tests for opening a section in the Files app

❤️

Copy link
Member

@MorrisJobke MorrisJobke left a comment

Choose a reason for hiding this comment

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

Tested and works 👍

@MorrisJobke
Copy link
Member

CI failure is a false positive ;)

@MorrisJobke
Copy link
Member

@danxuliu Could you open the stable14 backport PR?

@danxuliu
Copy link
Member Author

Could you open the stable14 backport PR?

Done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Opening "recent files" a second time shows empty files list
3 participants