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

[stable27] Fix opening "Remote shares" dialog even if Notifications is available #44823

Conversation

danxuliu
Copy link
Member

@danxuliu danxuliu commented Apr 15, 2024

This fix is only for Nextcloud 27; in Nextcloud 28, even if the fix would also apply, the federated files plugin is currently not loaded due to the changes in the Files app, so additional fixes are needed for this one to have any effect.

Since Nextcloud 25, when a user opens the Files app a Remote share dialog is shown to accept each pending remote share. However, this is a regression rather than a feature.

The dialog has been there already for ages, but it was supposed to be shown only if the Notifications app is not available, and to know whether the app is available or not it is checked if the header contains the Notifications button. However, in Nextcloud 25 the DOM of the Notifications app changed, so the button is no longer found and thus the dialog is always shown when there are pending shares.

Even if the correct element query was used the dialog may be still shown anyway if external.js is loaded before the notifications button is added to the header. Therefore now it is checked if the Notifications app is available or not from the OC API.

Note that, with the fixed behaviour, it is possible to remove a notification about a pending share without accepting it, and once the notification is removed it will not appear again (unlike the Remote share dialog, which appears again and again whenever you open the Files app if there is a pending share; this is specially noticeable with group shares, as declined group shares are marked as pending rather than removed). Nevertheless, in that case the user could open the Pending shares entry in the Files app navigation and accept the share from there if needed (this would be possible in Nextcloud 27 and earlier; in Nextcloud 28 and later remote shares are not listed in share views due to a bug).

How to test

  • Setup Nextcloud server A
  • Setup Nextcloud server B
  • Enable notifications app in server B
  • In server A, share a file with user X of server B
  • In server B, log in as user X
  • Open the Files app

Result with this pull request

The "Remote share" dialog is not shown, but the share can be accepted from the notification

Result without this pull request

The "Remote share" dialog is shown, even if there is also a notification to accept the share

…lable

The dialog is supposed to be shown only if the Notifications app is not
available, and to know whether it is available or not it is checked if
the header contains the Notifications button. However, in Nextcloud 25
the DOM of the Notifications app changed, so the button is no longer
found and thus the dialog was always shown when there are pending
shares.

Even if the correct element query was used the dialog may be still shown
anyway if "external.js" is loaded before the notifications button is
added to the header. Therefore now it is checked if the Notifications
app is available or not from the OC API.

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
@@ -78,7 +78,7 @@
this.filesApp = filesApp;
this.processIncomingShareFromUrl();

if (!$('#header').find('div.notifications').length) {
if (!('notifications' in OC.appswebroots)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

A bit hacky I think, but works and is better than the old version.

@susnux susnux merged commit 73da60d into stable27 Apr 15, 2024
38 checks passed
@susnux susnux deleted the fix-opening-remote-shares-dialog-even-if-notifications-is-available branch April 15, 2024 14:01
@Altahrim Altahrim mentioned this pull request Apr 17, 2024
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants