2020-11-23 11:07:07 +03:00
|
|
|
module Main exposing (..)
|
|
|
|
|
|
|
|
{-| Copyright 2020 Fluence Labs Limited
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
|
|
|
|
-}
|
|
|
|
|
|
|
|
import Browser exposing (Document)
|
2020-11-23 15:44:45 +03:00
|
|
|
import Browser.Navigation as Navigation
|
2020-11-23 11:07:07 +03:00
|
|
|
import Config exposing (Flags)
|
2020-11-23 15:44:45 +03:00
|
|
|
import Dict
|
|
|
|
import Model exposing (Model)
|
2020-11-23 14:27:33 +03:00
|
|
|
import Msg exposing (Msg(..))
|
2020-11-23 16:31:31 +03:00
|
|
|
import Route
|
2020-11-23 11:07:07 +03:00
|
|
|
import Subscriptions exposing (subscriptions)
|
|
|
|
import Update exposing (update)
|
2020-11-23 14:27:33 +03:00
|
|
|
import Url
|
2020-11-23 15:44:45 +03:00
|
|
|
import View exposing (view)
|
|
|
|
|
2020-11-23 11:07:07 +03:00
|
|
|
|
|
|
|
main =
|
2020-11-23 14:27:33 +03:00
|
|
|
Browser.application
|
2020-11-23 11:07:07 +03:00
|
|
|
{ init = init
|
|
|
|
, view = view
|
|
|
|
, update = update
|
|
|
|
, subscriptions = subscriptions
|
2020-11-23 15:44:45 +03:00
|
|
|
, onUrlChange = UrlChanged
|
|
|
|
, onUrlRequest = LinkClicked
|
2020-11-23 11:07:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-23 14:27:33 +03:00
|
|
|
init : Flags -> Url.Url -> Navigation.Key -> ( Model, Cmd Msg )
|
2020-11-23 15:44:45 +03:00
|
|
|
init flags url key =
|
2020-11-23 11:07:07 +03:00
|
|
|
let
|
2020-11-23 16:31:31 +03:00
|
|
|
r =
|
|
|
|
Route.parse url
|
|
|
|
|
2020-11-23 15:44:45 +03:00
|
|
|
emptyModel =
|
|
|
|
{ peerId = flags.peerId
|
|
|
|
, relayId = flags.relayId
|
|
|
|
, url = url
|
|
|
|
, key = key
|
2020-11-23 16:31:31 +03:00
|
|
|
, page = r
|
2020-11-23 17:39:32 +03:00
|
|
|
, discoveredPeers = Dict.empty
|
2020-12-01 14:51:12 +03:00
|
|
|
, modules = Dict.empty
|
|
|
|
, blueprints = Dict.empty
|
2020-12-01 17:47:52 +03:00
|
|
|
, toggledInterface = Nothing
|
2020-12-04 12:21:09 +03:00
|
|
|
, knownPeers = flags.knownPeers
|
2020-11-23 15:44:45 +03:00
|
|
|
}
|
2020-11-23 11:07:07 +03:00
|
|
|
in
|
2020-11-23 16:31:31 +03:00
|
|
|
( emptyModel, Route.routeCommand emptyModel r )
|