Clearing out some more warnings

This commit is contained in:
Gordon Pedersen 2024-07-02 10:13:52 +10:00
parent fd0300fccb
commit 822bf52407
17 changed files with 62 additions and 43 deletions

View file

@ -194,7 +194,7 @@ namespace Neighbourhood.omg.lol
public async Task<PutPicResponseData?> PutPic(string address, byte[] bytes) => public async Task<PutPicResponseData?> PutPic(string address, byte[] bytes) =>
await PutPic(address, Convert.ToBase64String(bytes)); await PutPic(address, Convert.ToBase64String(bytes));
public async Task<PutPicResponseData?> PostPicDescription(string address, string id, string description) => public async Task<PutPicResponseData?> PostPicDescription(string address, string id, string? description) =>
(await Post<PutPicResponseData, PostPic>($"/address/{address}/pics/{id}", new PostPic { Description = description })); (await Post<PutPicResponseData, PostPic>($"/address/{address}/pics/{id}", new PostPic { Description = description }));
public async Task<BasicResponseData?> DeletePic(string address, string id) => public async Task<BasicResponseData?> DeletePic(string address, string id) =>
(await Delete<BasicResponseData>($"/address/{address}/pics/{id}")); (await Delete<BasicResponseData>($"/address/{address}/pics/{id}"));

View file

@ -52,10 +52,11 @@
public string? Description { get; set; } public string? Description { get; set; }
private bool loading = false; private bool loading = false;
[Parameter] [Parameter]
public string id { get; set; } public string? id { get; set; }
private bool confirmDelete { get; set; } private bool confirmDelete { get; set; }
protected override async Task OnInitializedAsync() { protected override async Task OnInitializedAsync() {
await base.OnInitializedAsync();
Description = Pic?.Description; Description = Pic?.Description;
} }
@ -70,7 +71,7 @@
await InvokeAsync(StateHasChanged); await InvokeAsync(StateHasChanged);
if (!string.IsNullOrEmpty(Pic?.Id)) { if (!string.IsNullOrEmpty(Pic?.Id)) {
await api.DeletePic(State.SelectedAddressName, Pic.Id); await api.DeletePic(State.SelectedAddressName!, Pic.Id);
await State.RefreshPics(); await State.RefreshPics();
State.SendRefresh(); State.SendRefresh();
await InvokeAsync(StateHasChanged); await InvokeAsync(StateHasChanged);
@ -91,7 +92,7 @@
await InvokeAsync(StateHasChanged); await InvokeAsync(StateHasChanged);
if(!string.IsNullOrEmpty(Pic?.Id)) { if(!string.IsNullOrEmpty(Pic?.Id)) {
await api.PostPicDescription(State.SelectedAddressName, Pic.Id, Description); await api.PostPicDescription(State.SelectedAddressName!, Pic.Id, Description);
await State.RefreshPics(); await State.RefreshPics();
State.SendRefresh(); State.SendRefresh();
await InvokeAsync(StateHasChanged); await InvokeAsync(StateHasChanged);

View file

@ -70,10 +70,11 @@
public string? Emoji { get; set; } public string? Emoji { get; set; }
private bool loading = false; private bool loading = false;
[Parameter] [Parameter]
public string id { get; set; } public string? id { get; set; }
private bool confirmDelete { get; set; } private bool confirmDelete { get; set; }
protected override async Task OnInitializedAsync() { protected override async Task OnInitializedAsync() {
await base.OnInitializedAsync();
Content = Status?.Content; Content = Status?.Content;
Emoji = Status?.Emoji; Emoji = Status?.Emoji;
} }
@ -89,7 +90,7 @@
await InvokeAsync(StateHasChanged); await InvokeAsync(StateHasChanged);
if (!string.IsNullOrEmpty(Status?.Id)) { if (!string.IsNullOrEmpty(Status?.Id)) {
await api.DeleteStatus(State.SelectedAddressName, Status.Id); await api.DeleteStatus(State.SelectedAddressName!, Status.Id);
await State.RefreshStatuses(); await State.RefreshStatuses();
State.SendRefresh(); State.SendRefresh();
await InvokeAsync(StateHasChanged); await InvokeAsync(StateHasChanged);
@ -111,7 +112,7 @@
await InvokeAsync(StateHasChanged); await InvokeAsync(StateHasChanged);
if (!string.IsNullOrEmpty(Status?.Id)) { if (!string.IsNullOrEmpty(Status?.Id)) {
await api.PatchStatus(State.SelectedAddressName, Status.Id, Content, Emoji); await api.PatchStatus(State.SelectedAddressName!, Status.Id, Content ?? String.Empty, Emoji);
await State.RefreshStatuses(); await State.RefreshStatuses();
State.SendRefresh(); State.SendRefresh();
await InvokeAsync(StateHasChanged); await InvokeAsync(StateHasChanged);

View file

@ -7,9 +7,9 @@
@code { @code {
[Parameter] [Parameter]
public string Url { get; set; } public string? Url { get; set; }
[Parameter] [Parameter]
public string id { get; set; } public string? id { get; set; }
public MarkupString? Html { get; set; } public MarkupString? Html { get; set; }
protected override async Task OnAfterRenderAsync(bool firstRender) { protected override async Task OnAfterRenderAsync(bool firstRender) {
@ -19,13 +19,13 @@
} }
public async Task Reload() { public async Task Reload() {
// if (Html == null){ if (Url != null){
Html = await api.GetHtml(Url); Html = await api.GetHtml(Url);
string? HtmlString = Html?.ToString(); string? HtmlString = Html?.ToString();
HtmlString = HtmlString?.Replace("</head>", "<base target='_blank'></head>"); HtmlString = HtmlString?.Replace("</head>", "<base target='_blank'></head>");
HtmlString = HtmlString?.Replace("</body>", "<script src='https://cdn.jsdelivr.net/npm/@iframe-resizer/child'></script></body>"); HtmlString = HtmlString?.Replace("</body>", "<script src='https://cdn.jsdelivr.net/npm/@iframe-resizer/child'></script></body>");
Html = (MarkupString)HtmlString; Html = (MarkupString)(HtmlString ?? string.Empty);
// } }
await InvokeAsync(StateHasChanged); await InvokeAsync(StateHasChanged);
} }
} }

View file

@ -19,5 +19,5 @@
@code { @code {
[Parameter] [Parameter]
public string @class { get; set; } public string? @class { get; set; }
} }

View file

@ -8,9 +8,9 @@
@code { @code {
[Parameter] [Parameter]
public string id { get; set; } public string? id { get; set; }
[Parameter] [Parameter]
public string? @class { get; set; } public string? @class { get; set; }
[Parameter] [Parameter]
public string icon { get; set; } public string? icon { get; set; }
} }

View file

@ -32,7 +32,7 @@
@code { @code {
[Parameter] [Parameter]
public string id { get; set; } public string? id { get; set; }
[Parameter] [Parameter]
public bool Active { get; set; } public bool Active { get; set; }
[Parameter] [Parameter]

View file

@ -55,7 +55,7 @@
[Parameter] [Parameter]
public string? Description { get; set; } public string? Description { get; set; }
[Parameter] [Parameter]
public string id { get; set; } public string? id { get; set; }
[Parameter] [Parameter]
public bool Active { get; set; } public bool Active { get; set; }
@ -74,9 +74,9 @@
loading = true; loading = true;
await InvokeAsync(StateHasChanged); await InvokeAsync(StateHasChanged);
PutPicResponseData? response = await api.PutPic(State.SelectedAddressName, Base64File); PutPicResponseData? response = await api.PutPic(State.SelectedAddressName!, Base64File!);
if(!string.IsNullOrEmpty(Description) && response != null && !string.IsNullOrEmpty(response.Id)) { if(!string.IsNullOrEmpty(Description) && response != null && !string.IsNullOrEmpty(response.Id)) {
await api.PostPicDescription(State.SelectedAddressName, response.Id, Description); await api.PostPicDescription(State.SelectedAddressName!, response.Id, Description);
await State.RefreshPics(); await State.RefreshPics();
State.SendRefresh(); State.SendRefresh();
await InvokeAsync(StateHasChanged); await InvokeAsync(StateHasChanged);
@ -116,8 +116,17 @@
} }
private async Task PopulateFileDetails() { private async Task PopulateFileDetails() {
if (File == null)
{
FileContentType = null;
FileSize = null;
Base64File = null;
}
else
{
FileContentType = File.ContentType; FileContentType = File.ContentType;
FileSize = await Utilities.FileSize(File); FileSize = await Utilities.FileSize(File);
Base64File = await Utilities.Base64FromFile(File); Base64File = await Utilities.Base64FromFile(File);
} }
}
} }

View file

@ -52,7 +52,7 @@
@code { @code {
[Parameter] [Parameter]
public string id { get; set; } public string? id { get; set; }
[Parameter] [Parameter]
public bool Active { get; set; } public bool Active { get; set; }
[Parameter] [Parameter]

View file

@ -13,9 +13,9 @@
@code { @code {
[Parameter] [Parameter]
public string icon { get; set; } public string? icon { get; set; }
[Parameter] [Parameter]
public string title { get; set; } public string? title { get; set; }
[Parameter] [Parameter]
public RenderFragment Description { get; set; } public RenderFragment? Description { get; set; }
} }

View file

@ -30,22 +30,22 @@
</nav> </nav>
@code { @code {
private MarkdownEditor Editor; private MarkdownEditor? Editor;
private bool listed; private bool listed;
private string markdownValue; private string? markdownValue;
private bool loading = false; private bool loading = false;
protected override async Task OnInitializedAsync() { protected override async Task OnInitializedAsync() {
await base.OnInitializedAsync(); await base.OnInitializedAsync();
NowContentData? data = await api.GetNowPage(State.SelectedAddressName); NowContentData? data = await api.GetNowPage(State.SelectedAddressName!);
if (data != null) if (data != null)
{ {
listed = data.Listed == 1; listed = data.Listed == 1;
markdownValue = data.Content; markdownValue = data.Content;
await Editor.SetValueAsync(markdownValue); await Editor!.SetValueAsync(markdownValue);
} }
InvokeAsync(StateHasChanged); await InvokeAsync(StateHasChanged);
} }
Task OnMarkdownValueChanged(string value) { Task OnMarkdownValueChanged(string value) {
@ -55,7 +55,7 @@
public async Task Save() { public async Task Save() {
loading = true; loading = true;
await InvokeAsync(StateHasChanged); await InvokeAsync(StateHasChanged);
var result = await api.PostNowPage(State.SelectedAddressName, markdownValue, listed); var result = await api.PostNowPage(State.SelectedAddressName!, markdownValue ?? string.Empty, listed);
if (result != null) { if (result != null) {
await State.RefreshNow(); await State.RefreshNow();
await InvokeAsync(StateHasChanged); await InvokeAsync(StateHasChanged);

View file

@ -17,7 +17,7 @@
</AuthorizeView> </AuthorizeView>
@code { @code {
public string SharePhoto { get; set; } public string? SharePhoto { get; set; }
public long? SharePhotoSize { get; set; } public long? SharePhotoSize { get; set; }
public string? SharePhotoContentType { get; set; } public string? SharePhotoContentType { get; set; }
public string? SharePhotoText { get; set; } public string? SharePhotoText { get; set; }

View file

@ -35,22 +35,22 @@
@code { @code {
[Parameter] [Parameter]
public Pic Pic {get; set;} public Pic? Pic {get; set;}
[Parameter] [Parameter]
public bool Editable { get; set; } = false; public bool Editable { get; set; } = false;
[Parameter] [Parameter]
public EditPicDialog? Dialog { get; set; } public EditPicDialog? Dialog { get; set; }
private async Task EditPic(EventArgs e){ private async Task EditPic(EventArgs e){
Dialog.Pic = Pic; Dialog!.Pic = Pic;
await InvokeAsync(StateHasChanged); await InvokeAsync(StateHasChanged);
await JS.InvokeVoidAsync("ui", "#" + Dialog?.id); await JS.InvokeVoidAsync("ui", "#" + Dialog?.id);
} }
public async Task ShareClick(EventArgs e){ public async Task ShareClick(EventArgs e){
await Share.Default.RequestAsync(new ShareTextRequest{ await Share.Default.RequestAsync(new ShareTextRequest{
Uri = Pic.Url, Uri = Pic!.Url,
Text = Pic.Description, Text = Pic!.Description,
Title = "I saw this on some.pics", Title = "I saw this on some.pics",
Subject = "I saw this on some.pics" Subject = "I saw this on some.pics"
}); });

View file

@ -14,7 +14,7 @@
@code { @code {
[Parameter] [Parameter]
public Func<bool, Task<List<Pic>?>> PicsFunc { get; set; } public Func<bool, Task<List<Pic>?>>? PicsFunc { get; set; }
[Parameter] [Parameter]
public bool Editable { get; set; } = false; public bool Editable { get; set; } = false;
@ -25,6 +25,8 @@
// TODO: There is a noticable rendering delay between the pics loading and the page rendering // TODO: There is a noticable rendering delay between the pics loading and the page rendering
protected override async Task OnInitializedAsync() { protected override async Task OnInitializedAsync() {
await base.OnInitializedAsync(); await base.OnInitializedAsync();
if (PicsFunc == null) return;
if (pics == null || pics.Count == 0) pics = await PicsFunc(false); if (pics == null || pics.Count == 0) pics = await PicsFunc(false);
State.PropertyChanged += StateChanged; State.PropertyChanged += StateChanged;
State.CanRefresh = true; State.CanRefresh = true;
@ -33,6 +35,8 @@
} }
private async void StateChanged(object? sender, PropertyChangedEventArgs e) { private async void StateChanged(object? sender, PropertyChangedEventArgs e) {
if (PicsFunc == null) return;
if (e.PropertyName == nameof(State.IsRefreshing) && State.IsRefreshing) { if (e.PropertyName == nameof(State.IsRefreshing) && State.IsRefreshing) {
using (State.GetRefreshToken()){ using (State.GetRefreshToken()){
pics = await PicsFunc(true); pics = await PicsFunc(true);

View file

@ -36,21 +36,21 @@
@code { @code {
[Parameter] [Parameter]
public Status Status { get; set; } public Status? Status { get; set; }
[Parameter] [Parameter]
public bool Editable { get; set; } = false; public bool Editable { get; set; } = false;
[Parameter] [Parameter]
public EditStatusDialog? Dialog { get; set; } public EditStatusDialog? Dialog { get; set; }
private async Task EditStatus(EventArgs e) { private async Task EditStatus(EventArgs e) {
Dialog.Status = Status; Dialog!.Status = Status;
await InvokeAsync(StateHasChanged); await InvokeAsync(StateHasChanged);
await JS.InvokeVoidAsync("ui", "#" + Dialog?.id); await JS.InvokeVoidAsync("ui", "#" + Dialog?.id);
} }
public async Task ShareClick(EventArgs e){ public async Task ShareClick(EventArgs e){
await Share.Default.RequestAsync(new ShareTextRequest{ await Share.Default.RequestAsync(new ShareTextRequest{
Text = $"{Status.Content}\n- from [@{Status.Address}]({Status.Url})", Text = $"{Status!.Content}\n- from [@{Status.Address}]({Status.Url})",
Title = "I saw this on status.lol", Title = "I saw this on status.lol",
Subject = "I saw this on status.lol" Subject = "I saw this on status.lol"
}); });

View file

@ -14,7 +14,7 @@
@code { @code {
[Parameter] [Parameter]
public Func<bool, Task<List<Status>?>> StatusFunc { get; set; } public Func<bool, Task<List<Status>?>>? StatusFunc { get; set; }
[Parameter] [Parameter]
public bool Editable { get; set; } = false; public bool Editable { get; set; } = false;
@ -24,6 +24,8 @@
protected override async Task OnInitializedAsync() { protected override async Task OnInitializedAsync() {
await base.OnInitializedAsync(); await base.OnInitializedAsync();
if (StatusFunc == null) return;
if (statuses == null || statuses.Count == 0) statuses = await StatusFunc(false); if (statuses == null || statuses.Count == 0) statuses = await StatusFunc(false);
State.PropertyChanged += StateChanged; State.PropertyChanged += StateChanged;
State.CanRefresh = true; State.CanRefresh = true;
@ -32,6 +34,8 @@
} }
private async void StateChanged(object? sender, PropertyChangedEventArgs e) { private async void StateChanged(object? sender, PropertyChangedEventArgs e) {
if (StatusFunc == null) return;
if (e.PropertyName == nameof(State.IsRefreshing) && State.IsRefreshing) { if (e.PropertyName == nameof(State.IsRefreshing) && State.IsRefreshing) {
using (State.GetRefreshToken()) { using (State.GetRefreshToken()) {
statuses = await StatusFunc(true); statuses = await StatusFunc(true);

View file

@ -6,6 +6,6 @@ using System.Threading.Tasks;
namespace Neighbourhood.omg.lol.Models { namespace Neighbourhood.omg.lol.Models {
public class PostPic { public class PostPic {
public string Description { get; set; } public string? Description { get; set; }
} }
} }