Cleaned up more warnings

This commit is contained in:
Gordon Pedersen 2024-07-02 10:29:50 +10:00
parent 822bf52407
commit 2274c34f07
26 changed files with 74 additions and 77 deletions

View file

@ -42,7 +42,7 @@ namespace Neighbourhood.omg.lol
string str = await response.Content.ReadAsStringAsync(); string str = await response.Content.ReadAsStringAsync();
try { try {
OmgLolResponse<T>? responseObj = await response.Content.ReadFromJsonAsync<OmgLolResponse<T>>(_serializerOptions, cancellationToken: cancellationToken); OmgLolResponse<T>? responseObj = await response.Content.ReadFromJsonAsync<OmgLolResponse<T>>(_serializerOptions, cancellationToken: cancellationToken);
if (responseObj != null && responseObj.Request.Success) { if (responseObj?.Request?.Success ?? false) {
responseData = responseObj.Response; responseData = responseObj.Response;
} }
} }
@ -66,7 +66,7 @@ namespace Neighbourhood.omg.lol
string str = await response.Content.ReadAsStringAsync(); string str = await response.Content.ReadAsStringAsync();
if (response.IsSuccessStatusCode) { if (response.IsSuccessStatusCode) {
OmgLolResponse<TResponse>? responseObj = await response.Content.ReadFromJsonAsync<OmgLolResponse<TResponse>>(_serializerOptions, cancellationToken: cancellationToken); OmgLolResponse<TResponse>? responseObj = await response.Content.ReadFromJsonAsync<OmgLolResponse<TResponse>>(_serializerOptions, cancellationToken: cancellationToken);
if (responseObj != null && responseObj.Request.Success) { if (responseObj?.Request?.Success ?? false) {
responseData = responseObj.Response; responseData = responseObj.Response;
} }
} }
@ -87,7 +87,7 @@ namespace Neighbourhood.omg.lol
HttpResponseMessage response = await _client.SendAsync(request, cancellationToken: cancellationToken); HttpResponseMessage response = await _client.SendAsync(request, cancellationToken: cancellationToken);
if (response.IsSuccessStatusCode) { if (response.IsSuccessStatusCode) {
OmgLolResponse<TResponse>? responseObj = await response.Content.ReadFromJsonAsync<OmgLolResponse<TResponse>>(_serializerOptions, cancellationToken: cancellationToken); OmgLolResponse<TResponse>? responseObj = await response.Content.ReadFromJsonAsync<OmgLolResponse<TResponse>>(_serializerOptions, cancellationToken: cancellationToken);
if (responseObj != null && responseObj.Request.Success) { if (responseObj?.Request?.Success ?? false) {
responseData = responseObj.Response; responseData = responseObj.Response;
} }
} }
@ -106,7 +106,7 @@ namespace Neighbourhood.omg.lol
string str = await response.Content.ReadAsStringAsync(); string str = await response.Content.ReadAsStringAsync();
if (response.IsSuccessStatusCode) { if (response.IsSuccessStatusCode) {
OmgLolResponse<TResponse>? responseObj = await response.Content.ReadFromJsonAsync<OmgLolResponse<TResponse>>(_serializerOptions, cancellationToken: cancellationToken); OmgLolResponse<TResponse>? responseObj = await response.Content.ReadFromJsonAsync<OmgLolResponse<TResponse>>(_serializerOptions, cancellationToken: cancellationToken);
if (responseObj != null && responseObj.Request.Success) { if (responseObj?.Request?.Success ?? false) {
responseData = responseObj.Response; responseData = responseObj.Response;
} }
} }
@ -126,7 +126,7 @@ namespace Neighbourhood.omg.lol
string str = await response.Content.ReadAsStringAsync(); string str = await response.Content.ReadAsStringAsync();
try { try {
OmgLolResponse<T>? responseObj = await response.Content.ReadFromJsonAsync<OmgLolResponse<T>>(_serializerOptions, cancellationToken: cancellationToken); OmgLolResponse<T>? responseObj = await response.Content.ReadFromJsonAsync<OmgLolResponse<T>>(_serializerOptions, cancellationToken: cancellationToken);
if (responseObj != null && responseObj.Request.Success) { if (responseObj?.Request?.Success ?? false) {
responseData = responseObj.Response; responseData = responseObj.Response;
} }
} }

View file

@ -100,7 +100,7 @@
</div> </div>
@code { @code {
private string _address; private string _address = string.Empty;
[Parameter] [Parameter]
public string Address { public string Address {
get => _address; get => _address;
@ -121,8 +121,8 @@
public ExternalPageComponent? NowPage { get; set; } public ExternalPageComponent? NowPage { get; set; }
public ExternalPageComponent? ProfilePage { get; set; } public ExternalPageComponent? ProfilePage { get; set; }
private StatusList StatusList { get; set; } private StatusList? StatusList { get; set; }
private PicList PicList { get; set; } private PicList? PicList { get; set; }
private bool IsMe { private bool IsMe {
get => Address == State.SelectedAddressName; get => Address == State.SelectedAddressName;

View file

@ -1,7 +1,7 @@
@inject IJSRuntime JS @inject IJSRuntime JS
<article class="no-padding"> <article class="no-padding">
<img src="@Pic.Url" loading="lazy"> <img src="@Pic!.Url" loading="lazy">
<div class="padding"> <div class="padding">
<nav> <nav>
<a class="author" href="/person/@Pic.Address#pics"> <a class="author" href="/person/@Pic.Address#pics">

View file

@ -1,6 +1,6 @@
@inject IJSRuntime JS @inject IJSRuntime JS
<article class="status gray-9-fg" style="background-color:@(Status.Background)"> <article class="status gray-9-fg" style="background-color:@(Status!.Background)">
<div class="row"> <div class="row">
<div class="emoji" data-emoji="@Status.EmojiOrDefault">@Status.EmojiOrDefault</div> <div class="emoji" data-emoji="@Status.EmojiOrDefault">@Status.EmojiOrDefault</div>
<div class="max"> <div class="max">

View file

@ -1,14 +1,9 @@
using System; namespace Neighbourhood.omg.lol.Models {
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Neighbourhood.omg.lol.Models {
public class AccountResponseData : IOmgLolResponseData { public class AccountResponseData : IOmgLolResponseData {
public string Message { get; set; } public string Message { get; set; } = string.Empty;
public string Email { get; set; } public string Email { get; set; } = string.Empty;
public string Name { get; set; } public string Name { get; set; } = string.Empty;
// created, api_key and settings public TimeData Created { get; set; } = TimeData.Empty;
} //TODO: api_key and settings
}
} }

View file

@ -6,10 +6,10 @@ using System.Threading.Tasks;
namespace Neighbourhood.omg.lol.Models { namespace Neighbourhood.omg.lol.Models {
public class AddressResponseData : IOmgLolResponseData { public class AddressResponseData : IOmgLolResponseData {
public string Address { get; set; } public string Address { get; set; } = string.Empty;
public string Message { get; set; } public string Message { get; set; } = string.Empty;
public RegistrationData Registration { get; set; } public RegistrationData? Registration { get; set; }
public ExpirationData Expiration { get; set; } public ExpirationData? Expiration { get; set; }
public PreferenceData? Preferences { get; set; } public PreferenceData? Preferences { get; set; }
public class RegistrationData : TimeData { public class RegistrationData : TimeData {

View file

@ -6,6 +6,6 @@ using System.Threading.Tasks;
namespace Neighbourhood.omg.lol.Models { namespace Neighbourhood.omg.lol.Models {
public class BasicResponseData : IOmgLolResponseData { public class BasicResponseData : IOmgLolResponseData {
public string Message { get; set; } public string Message { get; set; } = string.Empty;
} }
} }

View file

@ -6,8 +6,8 @@ using System.Threading.Tasks;
namespace Neighbourhood.omg.lol.Models { namespace Neighbourhood.omg.lol.Models {
public class DirectoryResponseData : IOmgLolResponseData { public class DirectoryResponseData : IOmgLolResponseData {
public string Message { get; set; } public string Message { get; set; } = string.Empty;
public string Url { get; set; } public string Url { get; set; } = string.Empty;
public List<string> Directory { get; set; } public List<string> Directory { get; set; } = new List<string>();
} }
} }

View file

@ -6,6 +6,6 @@ using System.Threading.Tasks;
namespace Neighbourhood.omg.lol.Models { namespace Neighbourhood.omg.lol.Models {
public class EphemeralData { public class EphemeralData {
public string Content { get; set; } public string Content { get; set; } = string.Empty;
} }
} }

View file

@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace Neighbourhood.omg.lol.Models { namespace Neighbourhood.omg.lol.Models {
public class EphemeralResponseData : IOmgLolResponseData { public class EphemeralResponseData : IOmgLolResponseData {
public string Message { get; set; } public string Message { get; set; } = string.Empty;
public List<string> Content { get; set; } public List<string> Content { get; set; } = new List<string>();
} }
} }

View file

@ -1,9 +1,9 @@
namespace Neighbourhood.omg.lol.Models namespace Neighbourhood.omg.lol.Models
{ {
public class NowData { public class NowData {
public string Address { get; set; } public string Address { get; set; } = string.Empty;
public string Url { get; set; } public string Url { get; set; } = string.Empty;
public TimeData Updated { get; set; } public TimeData Updated { get; set; } = TimeData.Empty;
public string UpdatedRelative { public string UpdatedRelative {
get => Utilities.RelativeTimeFromUnix(Convert.ToInt64(Updated.UnixEpochTime)); get => Utilities.RelativeTimeFromUnix(Convert.ToInt64(Updated.UnixEpochTime));

View file

@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace Neighbourhood.omg.lol.Models { namespace Neighbourhood.omg.lol.Models {
public class NowPageResponseData : IOmgLolResponseData { public class NowPageResponseData : IOmgLolResponseData {
public string Message { get; set; } public string Message { get; set; } = string.Empty;
public NowContentData Now { get; set; } public NowContentData? Now { get; set; }
} }
} }

View file

@ -6,8 +6,8 @@ using System.Threading.Tasks;
namespace Neighbourhood.omg.lol.Models { namespace Neighbourhood.omg.lol.Models {
public class NowResponseData : IOmgLolResponseData { public class NowResponseData : IOmgLolResponseData {
public string Message { get; set; } public string Message { get; set; } = string.Empty;
public long Count { get; set; } public long Count { get; set; }
public List<NowData> Garden { get; set; } public List<NowData> Garden { get; set; } = new List<NowData>();
} }
} }

View file

@ -1,6 +1,6 @@
namespace Neighbourhood.omg.lol.Models { namespace Neighbourhood.omg.lol.Models {
public class OmgLolResponse<TResponseData> where TResponseData : IOmgLolResponseData { public class OmgLolResponse<TResponseData> where TResponseData : IOmgLolResponseData {
public OmgLolRequestData Request { get; set; } public OmgLolRequestData? Request { get; set; }
public TResponseData Response { get; set; } public TResponseData? Response { get; set; }
} }
} }

View file

@ -6,8 +6,8 @@ using System.Threading.Tasks;
namespace Neighbourhood.omg.lol.Models { namespace Neighbourhood.omg.lol.Models {
public class PatchStatus { public class PatchStatus {
public string Id { get; set; } public string Id { get; set; } = string.Empty;
public string Content { get; set; } public string Content { get; set; } = string.Empty;
public string? Emoji { get; set; } public string? Emoji { get; set; }
} }
} }

View file

@ -6,8 +6,8 @@ using System.Threading.Tasks;
namespace Neighbourhood.omg.lol.Models { namespace Neighbourhood.omg.lol.Models {
public class PatchStatusResponseData : IOmgLolResponseData { public class PatchStatusResponseData : IOmgLolResponseData {
public string Message { get; set; } public string Message { get; set; } = string.Empty;
public string Id { get; set; } public string Id { get; set; } = string.Empty;
public string Url { get; set; } public string Url { get; set; } = string.Empty;
} }
} }

View file

@ -6,6 +6,6 @@ using System.Threading.Tasks;
namespace Neighbourhood.omg.lol.Models { namespace Neighbourhood.omg.lol.Models {
public class PutPic { public class PutPic {
public string Pic { get; set; } public string Pic { get; set; } = string.Empty;
} }
} }

View file

@ -6,10 +6,10 @@ using System.Threading.Tasks;
namespace Neighbourhood.omg.lol.Models { namespace Neighbourhood.omg.lol.Models {
public class PutPicResponseData : IOmgLolResponseData { public class PutPicResponseData : IOmgLolResponseData {
public string Message { get; set; } public string Message { get; set; } = string.Empty;
public string Id { get; set; } public string Id { get; set; } = string.Empty;
public long Size { get; set; } public long Size { get; set; }
public string Mime { get; set; } public string Mime { get; set; } = string.Empty;
public string Url { get; set; } public string Url { get; set; } = string.Empty;
} }
} }

View file

@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace Neighbourhood.omg.lol.Models { namespace Neighbourhood.omg.lol.Models {
public class SomePicsResponseData : IOmgLolResponseData { public class SomePicsResponseData : IOmgLolResponseData {
public string Message { get; set; } public string Message { get; set; } = string.Empty;
public List<Pic>? Pics { get; set; } public List<Pic>? Pics { get; set; }
} }
} }

View file

@ -6,9 +6,9 @@ using System.Threading.Tasks;
namespace Neighbourhood.omg.lol.Models { namespace Neighbourhood.omg.lol.Models {
public class StatusBioResponseData : IOmgLolResponseData { public class StatusBioResponseData : IOmgLolResponseData {
public string Message { get; set; } public string Message { get; set; } = string.Empty;
public string Bio { get; set; } public string Bio { get; set; } = string.Empty;
public string Css { get; set; } public string Css { get; set; } = string.Empty;
public string Head { get; set; } public string Head { get; set; } = string.Empty;
} }
} }

View file

@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace Neighbourhood.omg.lol.Models { namespace Neighbourhood.omg.lol.Models {
public class StatusResponseData : IOmgLolResponseData { public class StatusResponseData : IOmgLolResponseData {
public string Message { get; set; } public string Message { get; set; } = string.Empty;
public List<Status> Statuses { get; set; } public List<Status> Statuses { get; set; } = new List<Status>();
} }
} }

View file

@ -1,7 +1,7 @@
namespace Neighbourhood.omg.lol.Models { namespace Neighbourhood.omg.lol.Models {
public class TokenResponseData { public class TokenResponseData {
public string AccessToken { get; set; } public string AccessToken { get; set; } = string.Empty;
public string TokenType { get; set; } public string TokenType { get; set; } = string.Empty;
public string Scope { get; set; } public string Scope { get; set; } = string.Empty;
} }
} }

View file

@ -4,13 +4,13 @@ using System.Text.Json.Serialization;
namespace Neighbourhood.omg.lol.Models namespace Neighbourhood.omg.lol.Models
{ {
public class Pic { public class Pic {
public string Id { get; set; } public string Id { get; set; } = string.Empty;
public string Url { get; set; } public string Url { get; set; } = string.Empty;
public string Address { get; set; } public string Address { get; set; } = string.Empty;
public long Created { get; set; } public long Created { get; set; }
public long Size { get; set; } public long Size { get; set; }
public string Mime { get; set; } public string Mime { get; set; } = string.Empty;
public string Description { get; set; } public string Description { get; set; } = string.Empty;
public string DescriptionHtml { get => Description == null ? string.Empty : Utilities.MdToHtml(Description); } public string DescriptionHtml { get => Description == null ? string.Empty : Utilities.MdToHtml(Description); }
public DateTimeOffset CreatedTime { get => DateTimeOffset.UnixEpoch.AddSeconds(Created); } public DateTimeOffset CreatedTime { get => DateTimeOffset.UnixEpoch.AddSeconds(Created); }

View file

@ -3,16 +3,16 @@
namespace Neighbourhood.omg.lol.Models namespace Neighbourhood.omg.lol.Models
{ {
public class Status { public class Status {
public string Id { get; set; } public string Id { get; set; } = string.Empty;
public string Address { get; set; } public string Address { get; set; } = string.Empty;
public string Created { get; set; } public string Created { get; set; } = string.Empty;
public string RelativeTime { get; set; } public string RelativeTime { get; set; } = string.Empty;
public string Emoji { get; set; } public string Emoji { get; set; } = string.Empty;
public string Background { get; set; } public string Background { get; set; } = string.Empty;
public string BackgroundColor { get => Background; set => Background = "#" + value; } public string BackgroundColor { get => Background; set => Background = "#" + value; }
public string Content { get; set; } public string Content { get; set; } = string.Empty;
public string RenderedMarkdown { get; set; } public string RenderedMarkdown { get; set; } = string.Empty;
public string ExternalUrl { get; set; } public string ExternalUrl { get; set; } = string.Empty;
public DateTimeOffset CreatedTime { get => DateTimeOffset.UnixEpoch.AddSeconds(Convert.ToInt64(Created)); } public DateTimeOffset CreatedTime { get => DateTimeOffset.UnixEpoch.AddSeconds(Convert.ToInt64(Created)); }

View file

@ -10,5 +10,7 @@ namespace Neighbourhood.omg.lol.Models {
public string? Iso8601Time { get; set; } public string? Iso8601Time { get; set; }
public string? Rfc2822Time { get; set; } public string? Rfc2822Time { get; set; }
public string? RelativeTime { get; set; } public string? RelativeTime { get; set; }
public static TimeData Empty { get => new TimeData(); }
} }
} }

View file

@ -49,7 +49,7 @@ public partial class LoginWebViewPage : ContentPage
string? token = await api.OAuth(code, client_id, client_secret, redirect_uri); string? token = await api.OAuth(code, client_id, client_secret, redirect_uri);
if (!string.IsNullOrEmpty(token)) { if (!string.IsNullOrEmpty(token)) {
await ((CustomAuthenticationStateProvider)this.AuthStateProvider).Login(token); await ((CustomAuthenticationStateProvider)this.AuthStateProvider).Login(token);
NavigatorService.NavigationManager.NavigateTo(NavigatorService.NavigationManager.Uri, forceLoad: true); NavigatorService?.NavigationManager?.NavigateTo(NavigatorService.NavigationManager.Uri, forceLoad: true);
await Shell.Current.GoToAsync(".."); await Shell.Current.GoToAsync("..");
} }
} }