Giter Site home page Giter Site logo

Comments (3)

RadekVyM avatar RadekVyM commented on May 19, 2024

Hi @ziomek64,

thanks for informing me about the issue. Where exactly do you call SimpleToolkit.SimpleShell.SimpleShell.Current.GoToAsync($"//main");? Does the app crash even if this call is commented out?

from simpletoolkit.

ziomek64 avatar ziomek64 commented on May 19, 2024

It happens in OnAppearing for my login page. The app doesn't crash when its commented or with normal shell

protected override async void OnAppearing()
{
    var token = Preferences.Get("token", "default_value");
    bool validation = true;

    try
    {
        validation = false;
        if (token != "default_value")
        {
            IJsonSerializer serializer = new JsonNetSerializer();
            var provider = new UtcDateTimeProvider();
            IJwtValidator validator = new JwtValidator(serializer, provider);
            IBase64UrlEncoder urlEncoder = new JwtBase64UrlEncoder();
            IJwtAlgorithm algorithm = new HMACSHA256Algorithm(); // symmetric
            IJwtDecoder decoder = new JwtDecoder(serializer, validator, urlEncoder, algorithm);

            //TODO decoding z login taska i sprawdzanie expiry w ten sposob
            //var json = decoder.Decode(token);

            validation = true;
        }
    }
    catch (TokenExpiredException)
    {
        Preferences.Set("token", "default_value");
    }
    catch (SignatureVerificationException)
    {
        Preferences.Set("token", "default_value");
    }
    catch (InvalidTokenPartsException)
    {
        Preferences.Set("token", "default_value");
    }
    catch (HttpRequestException httpRequestException)
    {
        Debug.WriteLine(httpRequestException.Message);
        MainThread.BeginInvokeOnMainThread(() =>
        {
            var toast = Toast.Make("No internet.", duration, fontSize);

            toast.Show(cancellationTokenSource.Token);
        });
    }
    catch (Exception e)
    {
        Debug.WriteLine(e);
        if (e.Message.Contains("Unable to resolve host"))
        {
            MainThread.BeginInvokeOnMainThread(() =>
            {
                //DependencyService.Get<Toast>().Show("Unexpected error happened");

                var toast = Toast.Make("No internet.", duration, fontSize);

                toast.Show(cancellationTokenSource.Token);
            });
        }
        else
        {
            MainThread.BeginInvokeOnMainThread(() =>
            {
                //DependencyService.Get<Toast>().Show("Unexpected error happened");

                var toast = Toast.Make("Unexpected error happened.", duration, fontSize);

                toast.Show(cancellationTokenSource.Token);
            });
        }
    }
    finally
    {
        if (validation)
        {
            await SimpleToolkit.SimpleShell.SimpleShell.Current.GoToAsync($"//main");
        }
    }
}

Should simple shell be installed in platform specific projects too or not?

from simpletoolkit.

RadekVyM avatar RadekVyM commented on May 19, 2024

Hi @ziomek64,

I have finally tried to take a look at this issue. However, I probably will not be able to fix it because of the way how creating a handler for a ShellItem works.

A workaround to this issue is to delay the navigation using Task.Delay() a bit:

await Task.Delay(100);
await Shell.Current.GoToAsync($"//main");

The delay is needed only on the first navigation to the initial page. On subsequent navigations to that page and on other pages it should not be needed.

And by the way, I currently do not plan to continue developing the SimpleToolkit.SimpleShell.Controls package, so I do not recommend using that.

from simpletoolkit.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.