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 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 Utils.TaskExtras exposing (run)
|
|
|
|
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 15:44:45 +03:00
|
|
|
emptyModel =
|
|
|
|
{ peerId = flags.peerId
|
|
|
|
, relayId = flags.relayId
|
|
|
|
, url = url
|
|
|
|
, key = key
|
|
|
|
, loadedPeers = Dict.empty
|
|
|
|
}
|
2020-11-23 11:07:07 +03:00
|
|
|
in
|
2020-11-23 15:44:45 +03:00
|
|
|
( emptyModel, run <| UrlChanged url )
|