Skip to content

fix(drawer): external site links no longer stop working over time - #17445

Merged
alperozturk96 merged 4 commits into
nextcloud:masterfrom
about2crash:fix-drawer-external-links
Oct 9, 2026
Merged

alperozturk96 merged 4 commits into
nextcloud:masterfrom
about2crash:fix-drawer-external-links

Conversation

@about2crash

@about2crash about2crash commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

External link menu items are registered with MENU_ITEM_EXTERNAL_LINK + the link's local database _id. That column is AUTOINCREMENT and the link table is cleared and refilled on every refresh, so the IDs grow without bound. The click handler only accepted an offset of 0–100, so once the IDs passed that window every external link silently stopped responding, no error, and it never recovers.

Dispatch on the menu group the items were registered under, and resolve the link by ID instead of by display name. The latter also fixes two links sharing a display name opening the same URL.

Reproduced with a link at local ID 501 (menu item 612): on master the tap logs Unknown drawer menu item clicked and nothing happens.

🧪 Testing

Verified manually on a device: with a link at local ID 501 in external_links, the drawer entry does nothing on master and opens correctly with this change.

Added DrawerActivityIT#externalLinkWithIdBeyondLegacyRangeIsOpened, which inserts a link at ID 501 and asserts the drawer entry opens ExternalSiteWebView with the link URL.

🖼️ Screenshots

🏚️ Before (master)

record_before.mp4

🏡 After (this PR)

record_after.mp4

🏁 Checklist

  • ⛑️ Tests included
  • 🔙 Backport: maintainers can request one if needed.
  • 📅 Milestone: maintainers can add one if needed.
  • 🌸 PR title is meaningful (if it should be in the changelog: is it meaningful to users?)

🤖 AI (if applicable)

  • The content of this PR was partly or fully generated using AI

External link menu items are registered with MENU_ITEM_EXTERNAL_LINK + the link's local database _id. That column is AUTOINCREMENT and the link table is cleared and refilled on every refresh, so the IDs grow without bound. The click handler only accepted an offset of 0-100, so once the IDs passed that window every external link silently stopped responding.

Dispatch on the menu group the items were registered under, and resolve the link by ID instead of by display name.

Signed-off-by: about2crash <146389368+about2crash@users.noreply.github.com>
Assisted-by: ClaudeCode:claude-opus-5
@github-actions

Copy link
Copy Markdown

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!

(If you believe you should not receive this message, you can add yourself to the blocklist.)

Signed-off-by: about2crash <146389368+about2crash@users.noreply.github.com>
@about2crash

Copy link
Copy Markdown
Contributor Author

Just pushed a fix for a recent merge conflict so this branch is fully up to date! @alperozturk96 would you be the right person to review this, or is there someone else I should ping? Let me know if you need any changes!

@@ -825,27 +823,28 @@ public void accountClicked(User user) {
}

private void externalLinkClicked(MenuItem menuItem) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Hello,

Thank you for the PR. Can we simplify the logic?

private void externalLinkClicked(MenuItem menuItem) {
        int linkId = menuItem.getItemId() - MENU_ITEM_EXTERNAL_LINK;

        externalLinksProvider.getExternalLink(ExternalLinkType.LINK, externalLinks -> {
            ExternalLink link = externalLinks.stream()
                .filter(candidate -> candidate.getId() == linkId)
                .findFirst()
                .orElse(null);

            if (link == null) {
                Log_OC.w(TAG, "No external link found for menu item: " + menuItem.getTitle());
            } else {
                openExternalLink(link);
            }
            return Unit.INSTANCE;
        });
    }

    private void openExternalLink(ExternalLink link) {
        if (link.getRedirect()) {
            IntentUtil.startLinkIntent(this, link.getUrl());
            return;
        }

        Intent intent = new Intent(getApplicationContext(), ExternalSiteWebView.class)
            .putExtra(ExternalSiteWebView.EXTRA_TITLE, link.getName())
            .putExtra(ExternalSiteWebView.EXTRA_URL, link.getUrl())
            .putExtra(ExternalSiteWebView.EXTRA_SHOW_SIDEBAR, true);
        startActivity(intent);
    }

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added the suggested simplification of the logic. Tested on a device with link IDs above 500 (normal and redirect links), works as expected.

Extract opening the link into openExternalLink() as suggested in review.

Signed-off-by: about2crash <146389368+about2crash@users.noreply.github.com>
@codecov

codecov Bot commented Oct 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 63.15789% with 7 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...m/owncloud/android/ui/activity/DrawerActivity.java 63.15% 3 Missing and 4 partials ⚠️

📢 Thoughts on this report? Let us know!

@alperozturk96
alperozturk96 merged commit 1b08c2f into nextcloud:master Oct 9, 2026
18 of 24 checks passed
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.

2 participants