progress commit

This commit is contained in:
limited_dev 2023-02-02 22:13:03 +01:00
parent 184ba3a096
commit 9fa145866a
2 changed files with 22 additions and 3 deletions

View file

@ -36,12 +36,15 @@
<RadzenTextArea Placeholder="Content..." @bind-Value="@postContent" Cols="30" Rows="6" Class="w-100"/> <RadzenTextArea Placeholder="Content..." @bind-Value="@postContent" Cols="30" Rows="6" Class="w-100"/>
</div> </div>
</div> </div>
</div> </div>
<div class="pd centered marg"> <div class="pd centered marg">
<FormInfo/> <FormInfo/>
<InputFile OnChange="@SingleUpload" type="file" accept="image/*"/> <InputFile OnChange="@SingleUpload" type="file" accept="image/*"/>
@if (hasErr)
{
<span class="postError">@postErr</span>
}
<RadzenButton class="pd" Click="@onPostClick" Text="Post!"></RadzenButton> <RadzenButton class="pd" Click="@onPostClick" Text="Post!"></RadzenButton>
</div> </div>
@ -79,6 +82,9 @@
this.StateHasChanged(); this.StateHasChanged();
} }
string postErr { get; set; }
bool hasErr { get; set; } = false;
private async Task onPostClick() private async Task onPostClick()
{ {
@ -86,9 +92,18 @@
var user = await cauthStateProvder.GetAuthenticationStateAsync(); var user = await cauthStateProvder.GetAuthenticationStateAsync();
var usr = user.User; var usr = user.User;
UserData foundusr = await UsersRepository.getUserByEmailAsync(usr.Identity.Name); UserData foundusr = await UsersRepository.getUserByEmailAsync(usr.Identity.Name);
if (foundusr == null)
{
hasErr = true;
postErr = "You are not logged in.";
return;
}
int userID = foundusr.UserID; int userID = foundusr.UserID;
if (foundusr.TimeBanned != -1) if (foundusr.TimeBanned != -1)
{
return; return;
}
foundusr.lastActionTimeStamp = DateTimeOffset.UnixEpoch.ToUnixTimeMilliseconds(); foundusr.lastActionTimeStamp = DateTimeOffset.UnixEpoch.ToUnixTimeMilliseconds();
await UsersRepository.updateUserAsync(foundusr); await UsersRepository.updateUserAsync(foundusr);

View file

@ -38,3 +38,7 @@
text-align: left; text-align: left;
display: flex; display: flex;
} }
.postError{
color: #ff191c;
}