Skip to content

Back button on Update.htm #4417

Closed
Closed

Description

@Jacobnordvall

What happened?

Back button dosnt go back to index if the last page wast index. aka you clicked on git banner to get latest bin.

To Reproduce Bug

Click the git banner. then use back gesture on android. then use the back botton. It now takes you back to the git page as it tracks the last page and dosnt actually go to index page.

Expected Behavior

back goes back to last entry in the main page.

Anything else?

Here is a fully working solution for reference:

function goBackToMainPage() {
    let stepsBack = 0;
    const mainPages = ['/#Colors', '/#Effects', '/#Segments', '/#Presets'];

    function isMainPage() {
        const currentPage = window.location.href;
        return mainPages.some(page => currentPage.includes(page));
    }

    function navigateBack() {
        if (stepsBack < 60) { // Prevent infinite loop
            stepsBack++;
            window.history.back();

            setTimeout(() => {
                if (!isMainPage()) {
                    navigateBack();
                }
            }, 100); // Wait for navigation to take effect
        } else {
            // Fallback if no "main" page is found
            window.location = '/';
        }
    }

    if (!isMainPage()) {
        navigateBack();
    } else {
        // If already on a main page
        console.log("You're already on a main page!");
    }
}

and ofc the html:

<button type="button" onclick="goBackToMainPage()">Back</button>

Code of Conduct

  • I agree to follow this project's Code of Conduct

Activity

  1. Jacobnordvall commented on Dec 22, 2024

    @Jacobnordvall
    Author

    that code (or a similar fix) should also be used for the settings back button preferably. as it goes back to the actuall last index page and not just to colors no matter what.

  2. blazoncek commented on Dec 23, 2024

    @blazoncek
    Contributor

    Make a PR, please.

  3. Jacobnordvall commented on Dec 24, 2024

    @Jacobnordvall
    Author

    Make a PR, please.

    Want me to put that . function in common.js?
    As it can be used for proper back functionality for settings page too and others?

    Or just a simplified version that just goes back to colors for uniformity and only keep that proper back function in update.htm? Seen as im not sure you can mess up on any other page and all. Actually. Im sure there are other scenarios it also has the potential to break. Anyways. Not sure what the philosophy is here so you tell me.

  4. DedeHai commented on Dec 24, 2024

    @DedeHai
    Collaborator

    keep in mind that flash memory is at a premium, keep the code as compact as possible even if it means cutting corners, IMHO this is solving an inconvenience which currently minimal code should be spent on.

  5. blazoncek commented on Dec 24, 2024

    @blazoncek
    Contributor

    Also verify functionality behind reverse proxy.

  6. Jacobnordvall commented on Dec 26, 2024

    @Jacobnordvall
    Author

    Also verify functionality behind reverse proxy.

    im not entirely sure what that means tbh.
    its a line swap fix. if its just to adress the bug.

    Pull request

  7. blazoncek commented on Dec 27, 2024

    @blazoncek
    Contributor

    The behaviour is correct and expected one. When you click/tap Github link, a new tab/window is opened. It has no history and so cannot go back while the Update page correctly returns to previous window.

  8. Jacobnordvall commented on Dec 27, 2024

    @Jacobnordvall
    Author

    The behaviour is correct and expected one. When you click/tap Github link, a new tab/window is opened. It has no history and so cannot go back while the Update page correctly returns to previous window.

    Its not. Its broken in the wled app.

  9. blazoncek commented on Dec 28, 2024

    @blazoncek
    Contributor

    Then open an issue in WLED app.
    I am truly sorry for you but WLED behaves correctly and as designed.

  10. added
    external
    on Dec 28, 2024
  11. Jacobnordvall commented on Dec 29, 2024

    @Jacobnordvall
    Author

    Well this isnt going to be fixed with an app update.
    Its wled not working well. And besides. Its broken in ap mode too. And the current way of handling is less performant too. I can create a pr to fix it all universally in wled but im guessing its no point as you see this behavior as intended?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    external

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions