v0.1.3 release

fixed some issues, forgot which ones
This commit is contained in:
limited_dev 2023-02-14 12:46:52 +01:00
parent 7f138cf73f
commit b25949a8f3
9 changed files with 35 additions and 7 deletions

View file

@ -1,4 +1,5 @@
<CascadingAuthenticationState>

<CascadingAuthenticationState>
<Router AppAssembly="@typeof(App).Assembly">
<Found Context="routeData">
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)"/>

View file

@ -21,6 +21,14 @@ public static class UsersRepository
return await db.Users.FirstOrDefaultAsync(user => user.UserID == userId);
}
public static async Task<UserData> getUserByEmailRawAsync(string email)
{
await using var db = new AppDBContext();
return await db.Users
.Where(user => user.Email == email)
.FirstOrDefaultAsync();
}
public static async Task<UserData> getUserByEmailAsync(string email)
{
await using var db = new AppDBContext();

View file

@ -10,6 +10,11 @@ public class TheManager
return (DateTimeOffset.Now.ToUnixTimeMilliseconds() - post.CreatedAt);
}
/// <summary>
/// Returns the value without a minus, if it exists
/// </summary>
/// <param name="num"></param>
/// <returns></returns>
private static long getValue(long num)
{
return num < 0 ? num * -1 : num;
@ -17,13 +22,13 @@ public class TheManager
public static long getBumpValue(PostData post)
{
return getValue( 10 * 60000 - getDiff(post)) + getDiff(post) / post.Comments.Count;
return 10 * 60000 - getDiff(post) + ( 60000 * (post.Comments.Count + 1));
}
public static async Task<List<PostData>> getPostList(string boardTag)
{
List<PostData> threads = await PostsRepository.getPostsByBoardAsync(boardTag);
return threads.OrderBy(getBumpValue).ToList();
return threads.OrderBy(getBumpValue).Reverse().ToList();
}
public static async Task bumpThreads(BoardData board)

View file

@ -30,7 +30,7 @@
private async Task login()
{
Console.WriteLine("loggin you in...");
var user = await UsersRepository.getUserByEmailAsync(Email);
var user = await UsersRepository.getUserByEmailRawAsync(Email);
if (user == null)
{
await js.InvokeVoidAsync("alert", "User does not exist");

View file

@ -43,7 +43,7 @@
}
await UsersRepository.createUserAsync(userToCreate);
var user = await UsersRepository.getUserByEmailAsync(Email);
var user = await UsersRepository.getUserByEmailRawAsync(Email);
if (user == null)
{
await js.InvokeVoidAsync("alert", "User does not exist");

View file

@ -4,7 +4,7 @@
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
<link rel="stylesheet" href="_content/Radzen.Blazor/css/material-dark.css">
<script src="_content/Radzen.Blazor/Radzen.Blazor.js"></script>
<!-- <script src="_content/Radzen.Blazor/Radzen.Blazor.js"></script> -->
<!DOCTYPE html>
<html lang="en">

View file

@ -153,6 +153,7 @@
{
//Open post successfull
NavigationManager.NavigateTo($"/{board.Tag}/thread/{postId}", true, true);
await TheManager.bumpThreads(board);
Console.WriteLine("Post created");
}
else

View file

@ -21,6 +21,12 @@
<span> </span>
<span class="date"> @getTimeFromUnix(post.CreatedAt)</span>
<span class="post-id">No.@post.PostID</span>
<AuthorizeView Roles="Admin,Mod">
<Authorized>
<span> </span>
<span>(@value)</span>
</Authorized>
</AuthorizeView>
</div>
@if (opened)
{
@ -99,12 +105,19 @@
private string toggleText = "-";
private string value;
private void ToggleOpened()
{
opened = !opened;
toggleText = opened ? "-" : "+";
}
protected override async Task OnInitializedAsync()
{
value = TheManager.getBumpValue(post) + "v";
}
[Parameter]
[Required]
public PostData post { get; set; }

View file

@ -4,7 +4,7 @@
<div class="top-row ps-3 navbar navbar-dark">
<div class="container-fluid">
<a class="navbar-brand" href="">ImageBoard</a>
<a class="navbar-brand" href="">IB v0.1.3</a>
<AuthorizeView>
<Authorized>
<a class="navbar-brand" @onclick="logout" href="javascript:void(0)">[Logout]</a>