about summary refs log tree commit diff
path: root/MatrixUtils.Web/Pages/Client/ClientComponents/ClientStatusList.razor
blob: 1100c98de22c983ad9b9f4d9cbcdae9928ff1dd6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
@using ClientContext = MatrixUtils.Web.Pages.Client.Index.ClientContext;
@using System.Collections.ObjectModel

@foreach (var ctx in Data) {
    <pre>
        @ctx.Homeserver.UserId - @ctx.SyncWrapper.Status
    </pre>
}

@code {

    [Parameter]
    public ObservableCollection<ClientContext> Data { get; set; } = null!;

    protected override void OnInitialized() {
        Data.CollectionChanged += (_, e) => {
            foreach (var item in e.NewItems?.Cast<ClientContext>() ?? []) {
                item.SyncWrapper.PropertyChanged += (_, pe) => {
                    if (pe.PropertyName == nameof(item.SyncWrapper.Status))
                        StateHasChanged();
                };
            }

            StateHasChanged();
        };

        Data.ToList().ForEach(ctx => {
            ctx.SyncWrapper.PropertyChanged += (_, pe) => {
                if (pe.PropertyName == nameof(ctx.SyncWrapper.Status))
                    StateHasChanged();
            };
        });
    }

}