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

Back button on Update.htm #4417

Closed
1 task done
Jacobnordvall opened this issue Dec 22, 2024 · 10 comments
Closed
1 task done

Back button on Update.htm #4417

Jacobnordvall opened this issue Dec 22, 2024 · 10 comments
Labels
external Not part of WLED itself - an external plugin/remote etc.

Comments

@Jacobnordvall
Copy link

Jacobnordvall commented Dec 22, 2024

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
@Jacobnordvall
Copy link
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.

@blazoncek
Copy link
Collaborator

Make a PR, please.

@Jacobnordvall
Copy link
Author

Jacobnordvall commented Dec 24, 2024

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.

@DedeHai
Copy link
Collaborator

DedeHai commented Dec 24, 2024

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.

@blazoncek
Copy link
Collaborator

Also verify functionality behind reverse proxy.

@Jacobnordvall
Copy link
Author

Jacobnordvall commented Dec 26, 2024

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

@blazoncek
Copy link
Collaborator

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.

@blazoncek blazoncek removed the bug label Dec 27, 2024
@Jacobnordvall
Copy link
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.

@blazoncek
Copy link
Collaborator

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

@blazoncek blazoncek added the external Not part of WLED itself - an external plugin/remote etc. label Dec 28, 2024
@Jacobnordvall
Copy link
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
Labels
external Not part of WLED itself - an external plugin/remote etc.
Projects
None yet
Development

No branches or pull requests

3 participants