Clearing out some more warnings
This commit is contained in:
parent
fd0300fccb
commit
822bf52407
17 changed files with 62 additions and 43 deletions
|
@ -194,7 +194,7 @@ namespace Neighbourhood.omg.lol
|
|||
public async Task<PutPicResponseData?> PutPic(string address, byte[] 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 }));
|
||||
public async Task<BasicResponseData?> DeletePic(string address, string id) =>
|
||||
(await Delete<BasicResponseData>($"/address/{address}/pics/{id}"));
|
||||
|
|
|
@ -52,10 +52,11 @@
|
|||
public string? Description { get; set; }
|
||||
private bool loading = false;
|
||||
[Parameter]
|
||||
public string id { get; set; }
|
||||
public string? id { get; set; }
|
||||
private bool confirmDelete { get; set; }
|
||||
|
||||
protected override async Task OnInitializedAsync() {
|
||||
await base.OnInitializedAsync();
|
||||
Description = Pic?.Description;
|
||||
}
|
||||
|
||||
|
@ -70,7 +71,7 @@
|
|||
await InvokeAsync(StateHasChanged);
|
||||
|
||||
if (!string.IsNullOrEmpty(Pic?.Id)) {
|
||||
await api.DeletePic(State.SelectedAddressName, Pic.Id);
|
||||
await api.DeletePic(State.SelectedAddressName!, Pic.Id);
|
||||
await State.RefreshPics();
|
||||
State.SendRefresh();
|
||||
await InvokeAsync(StateHasChanged);
|
||||
|
@ -91,7 +92,7 @@
|
|||
await InvokeAsync(StateHasChanged);
|
||||
|
||||
if(!string.IsNullOrEmpty(Pic?.Id)) {
|
||||
await api.PostPicDescription(State.SelectedAddressName, Pic.Id, Description);
|
||||
await api.PostPicDescription(State.SelectedAddressName!, Pic.Id, Description);
|
||||
await State.RefreshPics();
|
||||
State.SendRefresh();
|
||||
await InvokeAsync(StateHasChanged);
|
||||
|
|
|
@ -70,10 +70,11 @@
|
|||
public string? Emoji { get; set; }
|
||||
private bool loading = false;
|
||||
[Parameter]
|
||||
public string id { get; set; }
|
||||
public string? id { get; set; }
|
||||
private bool confirmDelete { get; set; }
|
||||
|
||||
protected override async Task OnInitializedAsync() {
|
||||
await base.OnInitializedAsync();
|
||||
Content = Status?.Content;
|
||||
Emoji = Status?.Emoji;
|
||||
}
|
||||
|
@ -89,7 +90,7 @@
|
|||
await InvokeAsync(StateHasChanged);
|
||||
|
||||
if (!string.IsNullOrEmpty(Status?.Id)) {
|
||||
await api.DeleteStatus(State.SelectedAddressName, Status.Id);
|
||||
await api.DeleteStatus(State.SelectedAddressName!, Status.Id);
|
||||
await State.RefreshStatuses();
|
||||
State.SendRefresh();
|
||||
await InvokeAsync(StateHasChanged);
|
||||
|
@ -111,7 +112,7 @@
|
|||
await InvokeAsync(StateHasChanged);
|
||||
|
||||
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();
|
||||
State.SendRefresh();
|
||||
await InvokeAsync(StateHasChanged);
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
|
||||
@code {
|
||||
[Parameter]
|
||||
public string Url { get; set; }
|
||||
public string? Url { get; set; }
|
||||
[Parameter]
|
||||
public string id { get; set; }
|
||||
public string? id { get; set; }
|
||||
public MarkupString? Html { get; set; }
|
||||
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender) {
|
||||
|
@ -19,13 +19,13 @@
|
|||
}
|
||||
|
||||
public async Task Reload() {
|
||||
// if (Html == null){
|
||||
if (Url != null){
|
||||
Html = await api.GetHtml(Url);
|
||||
string? HtmlString = Html?.ToString();
|
||||
HtmlString = HtmlString?.Replace("</head>", "<base target='_blank'></head>");
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,5 +19,5 @@
|
|||
|
||||
@code {
|
||||
[Parameter]
|
||||
public string @class { get; set; }
|
||||
public string? @class { get; set; }
|
||||
}
|
|
@ -8,9 +8,9 @@
|
|||
|
||||
@code {
|
||||
[Parameter]
|
||||
public string id { get; set; }
|
||||
public string? id { get; set; }
|
||||
[Parameter]
|
||||
public string? @class { get; set; }
|
||||
[Parameter]
|
||||
public string icon { get; set; }
|
||||
public string? icon { get; set; }
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
|
||||
@code {
|
||||
[Parameter]
|
||||
public string id { get; set; }
|
||||
public string? id { get; set; }
|
||||
[Parameter]
|
||||
public bool Active { get; set; }
|
||||
[Parameter]
|
||||
|
|
|
@ -55,7 +55,7 @@
|
|||
[Parameter]
|
||||
public string? Description { get; set; }
|
||||
[Parameter]
|
||||
public string id { get; set; }
|
||||
public string? id { get; set; }
|
||||
[Parameter]
|
||||
public bool Active { get; set; }
|
||||
|
||||
|
@ -74,9 +74,9 @@
|
|||
loading = true;
|
||||
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)) {
|
||||
await api.PostPicDescription(State.SelectedAddressName, response.Id, Description);
|
||||
await api.PostPicDescription(State.SelectedAddressName!, response.Id, Description);
|
||||
await State.RefreshPics();
|
||||
State.SendRefresh();
|
||||
await InvokeAsync(StateHasChanged);
|
||||
|
@ -116,8 +116,17 @@
|
|||
}
|
||||
|
||||
private async Task PopulateFileDetails() {
|
||||
FileContentType = File.ContentType;
|
||||
FileSize = await Utilities.FileSize(File);
|
||||
Base64File = await Utilities.Base64FromFile(File);
|
||||
if (File == null)
|
||||
{
|
||||
FileContentType = null;
|
||||
FileSize = null;
|
||||
Base64File = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
FileContentType = File.ContentType;
|
||||
FileSize = await Utilities.FileSize(File);
|
||||
Base64File = await Utilities.Base64FromFile(File);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@
|
|||
|
||||
@code {
|
||||
[Parameter]
|
||||
public string id { get; set; }
|
||||
public string? id { get; set; }
|
||||
[Parameter]
|
||||
public bool Active { get; set; }
|
||||
[Parameter]
|
||||
|
|
|
@ -13,9 +13,9 @@
|
|||
|
||||
@code {
|
||||
[Parameter]
|
||||
public string icon { get; set; }
|
||||
public string? icon { get; set; }
|
||||
[Parameter]
|
||||
public string title { get; set; }
|
||||
public string? title { get; set; }
|
||||
[Parameter]
|
||||
public RenderFragment Description { get; set; }
|
||||
public RenderFragment? Description { get; set; }
|
||||
}
|
||||
|
|
|
@ -30,22 +30,22 @@
|
|||
</nav>
|
||||
|
||||
@code {
|
||||
private MarkdownEditor Editor;
|
||||
private MarkdownEditor? Editor;
|
||||
private bool listed;
|
||||
private string markdownValue;
|
||||
private string? markdownValue;
|
||||
|
||||
private bool loading = false;
|
||||
|
||||
protected override async Task OnInitializedAsync() {
|
||||
await base.OnInitializedAsync();
|
||||
NowContentData? data = await api.GetNowPage(State.SelectedAddressName);
|
||||
NowContentData? data = await api.GetNowPage(State.SelectedAddressName!);
|
||||
if (data != null)
|
||||
{
|
||||
listed = data.Listed == 1;
|
||||
markdownValue = data.Content;
|
||||
await Editor.SetValueAsync(markdownValue);
|
||||
await Editor!.SetValueAsync(markdownValue);
|
||||
}
|
||||
InvokeAsync(StateHasChanged);
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
Task OnMarkdownValueChanged(string value) {
|
||||
|
@ -55,7 +55,7 @@
|
|||
public async Task Save() {
|
||||
loading = true;
|
||||
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) {
|
||||
await State.RefreshNow();
|
||||
await InvokeAsync(StateHasChanged);
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
</AuthorizeView>
|
||||
|
||||
@code {
|
||||
public string SharePhoto { get; set; }
|
||||
public string? SharePhoto { get; set; }
|
||||
public long? SharePhotoSize { get; set; }
|
||||
public string? SharePhotoContentType { get; set; }
|
||||
public string? SharePhotoText { get; set; }
|
||||
|
|
|
@ -35,22 +35,22 @@
|
|||
|
||||
@code {
|
||||
[Parameter]
|
||||
public Pic Pic {get; set;}
|
||||
public Pic? Pic {get; set;}
|
||||
[Parameter]
|
||||
public bool Editable { get; set; } = false;
|
||||
[Parameter]
|
||||
public EditPicDialog? Dialog { get; set; }
|
||||
|
||||
private async Task EditPic(EventArgs e){
|
||||
Dialog.Pic = Pic;
|
||||
Dialog!.Pic = Pic;
|
||||
await InvokeAsync(StateHasChanged);
|
||||
await JS.InvokeVoidAsync("ui", "#" + Dialog?.id);
|
||||
}
|
||||
|
||||
public async Task ShareClick(EventArgs e){
|
||||
await Share.Default.RequestAsync(new ShareTextRequest{
|
||||
Uri = Pic.Url,
|
||||
Text = Pic.Description,
|
||||
Uri = Pic!.Url,
|
||||
Text = Pic!.Description,
|
||||
Title = "I saw this on some.pics",
|
||||
Subject = "I saw this on some.pics"
|
||||
});
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
@code {
|
||||
[Parameter]
|
||||
public Func<bool, Task<List<Pic>?>> PicsFunc { get; set; }
|
||||
public Func<bool, Task<List<Pic>?>>? PicsFunc { get; set; }
|
||||
[Parameter]
|
||||
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
|
||||
protected override async Task OnInitializedAsync() {
|
||||
await base.OnInitializedAsync();
|
||||
if (PicsFunc == null) return;
|
||||
|
||||
if (pics == null || pics.Count == 0) pics = await PicsFunc(false);
|
||||
State.PropertyChanged += StateChanged;
|
||||
State.CanRefresh = true;
|
||||
|
@ -33,6 +35,8 @@
|
|||
}
|
||||
|
||||
private async void StateChanged(object? sender, PropertyChangedEventArgs e) {
|
||||
if (PicsFunc == null) return;
|
||||
|
||||
if (e.PropertyName == nameof(State.IsRefreshing) && State.IsRefreshing) {
|
||||
using (State.GetRefreshToken()){
|
||||
pics = await PicsFunc(true);
|
||||
|
|
|
@ -36,21 +36,21 @@
|
|||
|
||||
@code {
|
||||
[Parameter]
|
||||
public Status Status { get; set; }
|
||||
public Status? Status { get; set; }
|
||||
[Parameter]
|
||||
public bool Editable { get; set; } = false;
|
||||
[Parameter]
|
||||
public EditStatusDialog? Dialog { get; set; }
|
||||
|
||||
private async Task EditStatus(EventArgs e) {
|
||||
Dialog.Status = Status;
|
||||
Dialog!.Status = Status;
|
||||
await InvokeAsync(StateHasChanged);
|
||||
await JS.InvokeVoidAsync("ui", "#" + Dialog?.id);
|
||||
}
|
||||
|
||||
public async Task ShareClick(EventArgs e){
|
||||
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",
|
||||
Subject = "I saw this on status.lol"
|
||||
});
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
@code {
|
||||
[Parameter]
|
||||
public Func<bool, Task<List<Status>?>> StatusFunc { get; set; }
|
||||
public Func<bool, Task<List<Status>?>>? StatusFunc { get; set; }
|
||||
[Parameter]
|
||||
public bool Editable { get; set; } = false;
|
||||
|
||||
|
@ -24,6 +24,8 @@
|
|||
|
||||
protected override async Task OnInitializedAsync() {
|
||||
await base.OnInitializedAsync();
|
||||
if (StatusFunc == null) return;
|
||||
|
||||
if (statuses == null || statuses.Count == 0) statuses = await StatusFunc(false);
|
||||
State.PropertyChanged += StateChanged;
|
||||
State.CanRefresh = true;
|
||||
|
@ -32,6 +34,8 @@
|
|||
}
|
||||
|
||||
private async void StateChanged(object? sender, PropertyChangedEventArgs e) {
|
||||
if (StatusFunc == null) return;
|
||||
|
||||
if (e.PropertyName == nameof(State.IsRefreshing) && State.IsRefreshing) {
|
||||
using (State.GetRefreshToken()) {
|
||||
statuses = await StatusFunc(true);
|
||||
|
|
|
@ -6,6 +6,6 @@ using System.Threading.Tasks;
|
|||
|
||||
namespace Neighbourhood.omg.lol.Models {
|
||||
public class PostPic {
|
||||
public string Description { get; set; }
|
||||
public string? Description { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue