Coder Social home page Coder Social logo

Comments (2)

Freymaurer avatar Freymaurer commented on June 18, 2024 1

merged PR to developer

from swate.

Freymaurer avatar Freymaurer commented on June 18, 2024

I tried multiple alternatives for routing to fix this problem. All of which were very lackluster

  • non hash-based routing ->completly reload the page on each reroute
  • non hash-based routing with subpage as query param of Route.Home -> same issue as above

To fix most problems i first placed most of the init cmd messages in a batch after excel initializes. This fixed the reappearing yellow warning box that there is no annotationTable even though one was created before rerouting.

let init (pageOpt: Routing.Route option) : Model * Cmd<Msg> =
    let initialModel = initializeModel pageOpt
    let route = (parseHash Routing.Routing.route) Browser.Dom.document.location
    // The initial command from urlUpdate is not needed yet. As we use a reduced variant of subModels with no own Msg system.
    let model, _ = urlUpdate route initialModel
/// This is the important part. Only initializeAddIn is executed here
    let initialCmd =
        Cmd.batch [
            Cmd.OfPromise.either
                initializeAddIn
                ()
                (fun x -> (x.host.ToString(),x.platform.ToString()) |> Initialized |> ExcelInterop )
                (fun x -> x |> GenericError |> Dev)
        ]
    model, initialCmd

Instead the other init messages are now chained after initializeAddIn returned successful

    | Initialized (h,p) ->
        let welcomeMsg = sprintf "Ready to go in %s running on %s" h p

        let nextState = {
            currentState with
                Host        = h
                Platform    = p
        }
/// This is the important part. Only initializeAddIn is executed here
        let cmd =
            Cmd.batch [
                Cmd.ofMsg (FetchAllOntologies |> Request |> Api)
                Cmd.OfPromise.either
                    OfficeInterop.checkIfAnnotationTableIsPresent
                    ()
                    (AnnotationTableExists >> ExcelInterop)
                    (GenericError >> Dev)
                Cmd.ofMsg (("Info",welcomeMsg) |> (GenericLog >> Dev))
            ]

        nextState, cmd

After these steps the warning label shortly reappears but is then again removed, as after the excel init it finds that the table already exists.

BUT all of this can be fixed by using hash based rerouting only to navigate to a specific entrypoint to the app and then rerouting by updating the PageState in the model. This is implemented in commit e05d95a5 on my fork.

Will do a PR soon.

Edit: PR #40

from swate.

Related Issues (20)

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.