<commit_before>module Main exposing (main)

import Html exposing (..)
import Html.Attributes exposing (..)
import Set exposing (Set)
import Updates.UpdateAboutInfo exposing (updateAboutInfo)
import Updates.UpdateErrors exposing (updateErrors)
import Updates.UpdateLoginForm exposing (updateLoginForm)
import Updates.UpdateLoginStatus exposing (updateLoginStatus)
import Updates.UpdateBodyView exposing (updateBodyView)
import Updates.UpdateTemplates exposing (updateTemplates)
import Updates.Messages exposing (UpdateAboutInfoMsg(..), UpdateLoginStatusMsg(..), UpdateErrorsMsg(..), UpdateTemplatesMsg(..))
import Messages exposing (AnyMsg(..))
import Views.Header
import Views.Body
import Views.Footer
import Views.Notifications

import Model exposing (Model)

import Ws
import Websocket
import Dict exposing (Dict)

-- TODO what type of submessages do I want to have?
-- - Messages changing resources
-- - Error messages
-- - Messages changing the view
-- so one message per entry in my model? that means that not every single thing should define its own Msg type otherwise it will get crazy

init : ( Model, Cmd AnyMsg )
init =
  ( Model.initial
  , Ws.connect
  )

update : AnyMsg -> Model -> ( Model, Cmd AnyMsg )
update msg model =
  case msg of
    ProcessWsMsg wsMsg ->
      Ws.update wsMsg model
    SendWsMsg jsonObject wsMsgType ->
      ( model
      , Ws.send jsonObject wsMsgType
      )
    WsConnectError ( url, error ) ->
      let l = Debug.log "ConnectError" ( url, error )
      in
        ( model
        , Cmd.none
        )
    WsConnect url ->
      let l = Debug.log "Connect" url
      in
        ( { model | wsConnected = True }
        , Cmd.none
        )
    WsListenError ( url, error ) ->
      let l = Debug.log "ListenError" ( url, error )
      in
        ( model
        , Cmd.none
        )
    WsConnectionLost url -> -- TODO reconnect?
      let l = Debug.log "ConnectionLost" url
      in
        ( { model | wsConnected = False }
        , Cmd.none
        )
    WsMessage ( url, message ) ->
      Ws.update message model
    WsSendError ( url, message, error ) ->
      let l = Debug.log "SendError" ( url, message, error )
      in
        ( model
        , Cmd.none
        )
    WsSent ( url, message ) ->
      let l = Debug.log "Sent" ( url, message )
      in
        ( model
        , Cmd.none
        )
    UpdateAboutInfoMsg subMsg ->
      let (newAbout, cmd) =
        updateAboutInfo subMsg model.aboutInfo
      in
        ( { model | aboutInfo = newAbout }
        , cmd
        )
    UpdateLoginStatusMsg subMsg ->
      let (newLoginStatus, cmd) =
        updateLoginStatus subMsg model.loggedIn
      in
        ({ model | loggedIn = newLoginStatus }
        , cmd
        )<commit_msg>#181 add TODO<commit_after>module Main exposing (main)

import Html exposing (..)
import Html.Attributes exposing (..)
import Set exposing (Set)
import Updates.UpdateAboutInfo exposing (updateAboutInfo)
import Updates.UpdateErrors exposing (updateErrors)
import Updates.UpdateLoginForm exposing (updateLoginForm)
import Updates.UpdateLoginStatus exposing (updateLoginStatus)
import Updates.UpdateBodyView exposing (updateBodyView)
import Updates.UpdateTemplates exposing (updateTemplates)
import Updates.Messages exposing (UpdateAboutInfoMsg(..), UpdateLoginStatusMsg(..), UpdateErrorsMsg(..), UpdateTemplatesMsg(..))
import Messages exposing (AnyMsg(..))
import Views.Header
import Views.Body
import Views.Footer
import Views.Notifications

import Model exposing (Model)

import Ws
import Websocket
import Dict exposing (Dict)

-- TODO what type of submessages do I want to have?
-- - Messages changing resources
-- - Error messages
-- - Messages changing the view
-- so one message per entry in my model? that means that not every single thing should define its own Msg type otherwise it will get crazy

init : ( Model, Cmd AnyMsg )
init =
  ( Model.initial
  , Ws.connect
  )

update : AnyMsg -> Model -> ( Model, Cmd AnyMsg )
update msg model =
  case msg of
    ProcessWsMsg wsMsg ->
      Ws.update wsMsg model
    SendWsMsg jsonObject wsMsgType ->
      ( model
      , Ws.send jsonObject wsMsgType
      )
    WsConnectError ( url, error ) ->
      let l = Debug.log "ConnectError" ( url, error )
      in
        ( model
        , Cmd.none
        )
    WsConnect url ->
      let l = Debug.log "Connect" url
      in
        ( { model | wsConnected = True }
        , Cmd.none
        )
    WsListenError ( url, error ) ->
      let l = Debug.log "ListenError" ( url, error )
      in
        ( model
        , Cmd.none
        )
    WsConnectionLost url -> -- TODO reconnect?
      let l = Debug.log "ConnectionLost" url
      in
        ( { model | wsConnected = False } -- TODO what do I have to set here? all stuff should be unknown and disabled or so?
        , Cmd.none
        )
    WsMessage ( url, message ) ->
      Ws.update message model
    WsSendError ( url, message, error ) ->
      let l = Debug.log "SendError" ( url, message, error )
      in
        ( model
        , Cmd.none
        )
    WsSent ( url, message ) ->
      let l = Debug.log "Sent" ( url, message )
      in
        ( model
        , Cmd.none
        )
    UpdateAboutInfoMsg subMsg ->
      let (newAbout, cmd) =
        updateAboutInfo subMsg model.aboutInfo
      in
        ( { model | aboutInfo = newAbout }
        , cmd
        )
    UpdateLoginStatusMsg subMsg ->
      let (newLoginStatus, cmd) =
        updateLoginStatus subMsg model.loggedIn
      in
        ({ model | loggedIn = newLoginStatus }
        , cmd
        )
{'fraction_non_alphanumeric': 0.08841463414634146, 'fraction_numerical': 0.0005380200860832137, 'mean_word_length': 2.3535778713168973, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4203418', 'n_tokens_mistral': 1666, 'n_tokens_neox': 1588, 'n_words': 525}