<commit_before>﻿namespace Koffee

open System
open FSharp.Desktop.UI
open ConfigExt

type SettingsController(config: Config) =
    interface IController<SettingsEvents, SettingsModel> with
        member this.InitModel model =
            model.KeyBindings <-
                MainEvents.Bindable
                |> List.map (fun evt ->
                    let keys =
                        KeyBinding.DefaultsAsString
                        |> List.choose (fun (key, bound) ->
                            if bound = evt then Some key
                            else None)
                    {
                        EventName = evt.FriendlyName
                        BoundKeys = String.Join(" OR ", keys)
                    })

        member x.Dispatcher = function
            | StartupPathChanged value -> Sync (fun _ ->
                config.StartupPath <- value; config.Save())
            | DefaultPathChanged value -> Sync (fun _ ->
                config.DefaultPath <- value; config.Save())
            | TextEditorChanged value -> Sync (fun _ ->
                config.TextEditor <- value; config.Save())
            | PathFormatChanged value -> Sync (fun _ ->
                config.PathFormat <- value; config.Save())
            | ShowFullPathInTitleChanged value -> Sync (fun _ ->
                config.Window.ShowFullPathInTitle <- value; config.Save())
            | ShowHiddenChanged value -> Sync (fun _ ->
                config.ShowHidden <- value; config.Save())
<commit_msg>Refactors Settings InitModel.<commit_after>﻿namespace Koffee

open System
open FSharp.Desktop.UI
open Utility
open ConfigExt

type SettingsController(config: Config) =
    interface IController<SettingsEvents, SettingsModel> with
        member x.InitModel model =
            model.KeyBindings <-
                MainEvents.Bindable
                |> List.map (fun evt ->
                    { EventName = evt.FriendlyName
                      BoundKeys =
                        KeyBinding.DefaultsAsString
                        |> List.filter (snd >> ((=) evt))
                        |> List.map fst
                        |> Str.join " OR "
                    })

        member x.Dispatcher = function
            | StartupPathChanged value -> Sync (fun _ ->
                config.StartupPath <- value; config.Save())
            | DefaultPathChanged value -> Sync (fun _ ->
                config.DefaultPath <- value; config.Save())
            | TextEditorChanged value -> Sync (fun _ ->
                config.TextEditor <- value; config.Save())
            | PathFormatChanged value -> Sync (fun _ ->
                config.PathFormat <- value; config.Save())
            | ShowFullPathInTitleChanged value -> Sync (fun _ ->
                config.Window.ShowFullPathInTitle <- value; config.Save())
            | ShowHiddenChanged value -> Sync (fun _ ->
                config.ShowHidden <- value; config.Save())

{'fraction_non_alphanumeric': 0.09421768707482993, 'fraction_numerical': 0.0, 'mean_word_length': 1.4590301003344481, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 40, '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': '637171', 'n_tokens_mistral': 739, 'n_tokens_neox': 677, 'n_words': 172}