diff options
Diffstat (limited to 'MatrixUtils.Web/Shared/MxcImage.razor')
-rw-r--r-- | MatrixUtils.Web/Shared/MxcImage.razor | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/MatrixUtils.Web/Shared/MxcImage.razor b/MatrixUtils.Web/Shared/MxcImage.razor new file mode 100644 index 0000000..fb8c248 --- /dev/null +++ b/MatrixUtils.Web/Shared/MxcImage.razor @@ -0,0 +1,53 @@ +<img class="@Class" src="@ResolvedUri" style="@Style"/> +@code { + private string _mxcUri; + private string _style; + private string _resolvedUri; + + [Parameter] + public string MxcUri { + get => _mxcUri ?? ""; + set { + Console.WriteLine($"New MXC uri: {value}"); + _mxcUri = value; + UriHasChanged(value); + } + } + + //mxcuri binding + + + [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('/'); + Console.WriteLine($"UriHasChanged: {value} {uri[0]}"); + if (Homeserver is null) { + Console.WriteLine($"Homeserver is null, creating new remotehomeserver for {uri[0]}"); + Homeserver = await hsProvider.GetRemoteHomeserver(uri[0]); + } + ResolvedUri = Homeserver.ResolveMediaUri(value); + Console.WriteLine($"ResolvedUri: {ResolvedUri}"); + } + + [Parameter] + public string Class { get; set; } + +} \ No newline at end of file |