about summary refs log tree commit diff
path: root/MatrixRoomUtils.Web/Shared/MxcImage.razor
blob: f54c1f8e16b5686cb5bd3d1195a3a244d54f5a9d (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
36
37
38
39
40
41
42
43
<img class="@Class" src="@ResolvedUri" style="@Style"/>
@code {
    private string _mxcUri;
    private string _style;
    private string _resolvedUri;

    [Parameter]
    public string MxcUri {
        get => _mxcUri ?? "";
        set {
            _mxcUri = value;
            UriHasChanged(value);
        }
    }
    
    [Parameter]
    public string Style {
        get => _style;
        set {
            _style = value;
            StateHasChanged();
        }
    }
    [Parameter]
    public RemoteHomeserver? Homeserver { get; set; }

    private string ResolvedUri {
        get => _resolvedUri;
        set {
            _resolvedUri = value;
            StateHasChanged();
        }
    }

    private async Task UriHasChanged(string value) {
        var uri = value[5..].Split('/');
        ResolvedUri = (Homeserver ?? await hsProvider.GetRemoteHomeserver(uri[0])).ResolveMediaUri(value);
    }

    [Parameter]
    public string Class { get; set; }

}