<commit_before>﻿using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
using Money.UI.Blazor;
using Neptuo;
using Neptuo.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Money.Components.Bootstrap
{
    public class Native
    {
        private readonly IJSRuntime jsRuntime;
        private Dictionary<string, ModalBase> modals = new Dictionary<string, ModalBase>();

        public Native(IJSRuntime jsRuntime)
        {
            Ensure.NotNull(jsRuntime, "jsRuntime");
            this.jsRuntime = jsRuntime;
        }

        internal void AddModal(string id, ModalBase component)
        {
            modals[id] = component;
            jsRuntime.InvokeAsync<object>("Bootstrap.Modal.Register", id);
        }

        internal void ToggleModal(string id, bool isVisible) 
            => jsRuntime.InvokeAsync<object>("Bootstrap.Modal.Toggle", id, isVisible);

        internal void RemoveModal(string id)
            => modals.Remove(id);

        [JSInvokable]
        public void Bootstrap_ModalHidden(string id)
        {
            ILog log = Program.Resolve<ILogFactory>().Scope("Modal.Native");
            log.Debug($"Modal hidden '{id}'.");
            if (modals.TryGetValue(id, out ModalBase modal))
                modal.MarkAsHidden();
            else
                log.Debug($"Modal not found '{id}'.");
        }
    }
}
<commit_msg>#229 - Fix wasm exception after icon changed.<commit_after>﻿using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
using Money.UI.Blazor;
using Neptuo;
using Neptuo.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Money.Components.Bootstrap
{
    public class Native
    {
        private readonly IJSRuntime jsRuntime;
        private static Dictionary<string, ModalBase> modals = new Dictionary<string, ModalBase>();

        public Native(IJSRuntime jsRuntime)
        {
            Ensure.NotNull(jsRuntime, "jsRuntime");
            this.jsRuntime = jsRuntime;
        }

        internal void AddModal(string id, ModalBase component)
        {
            modals[id] = component;
            jsRuntime.InvokeAsync<object>("Bootstrap.Modal.Register", id);
        }

        internal void ToggleModal(string id, bool isVisible) 
            => jsRuntime.InvokeAsync<object>("Bootstrap.Modal.Toggle", id, isVisible);

        internal void RemoveModal(string id)
            => modals.Remove(id);

        [JSInvokable]
        public static void Bootstrap_ModalHidden(string id)
        {
            ILog log = Program.Resolve<ILogFactory>().Scope("Modal.Native");
            log.Debug($"Modal hidden '{id}'.");
            if (modals.TryGetValue(id, out ModalBase modal))
                modal.MarkAsHidden();
            else
                log.Debug($"Modal not found '{id}'.");
        }
    }
}

{'fraction_non_alphanumeric': 0.10552933243425489, 'fraction_numerical': 0.0010114632501685772, 'mean_word_length': 2.482394366197183, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 17, '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': '7481300', 'n_tokens_mistral': 812, 'n_tokens_neox': 811, 'n_words': 186}