v0.1.3 release
fixed some issues, forgot which ones
This commit is contained in:
parent
7f138cf73f
commit
b25949a8f3
9 changed files with 35 additions and 7 deletions
|
@ -1,4 +1,5 @@
|
||||||
<CascadingAuthenticationState>
|
|
||||||
|
<CascadingAuthenticationState>
|
||||||
<Router AppAssembly="@typeof(App).Assembly">
|
<Router AppAssembly="@typeof(App).Assembly">
|
||||||
<Found Context="routeData">
|
<Found Context="routeData">
|
||||||
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)"/>
|
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)"/>
|
||||||
|
|
|
@ -21,6 +21,14 @@ public static class UsersRepository
|
||||||
return await db.Users.FirstOrDefaultAsync(user => user.UserID == userId);
|
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)
|
public static async Task<UserData> getUserByEmailAsync(string email)
|
||||||
{
|
{
|
||||||
await using var db = new AppDBContext();
|
await using var db = new AppDBContext();
|
||||||
|
|
|
@ -10,6 +10,11 @@ public class TheManager
|
||||||
return (DateTimeOffset.Now.ToUnixTimeMilliseconds() - post.CreatedAt);
|
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)
|
private static long getValue(long num)
|
||||||
{
|
{
|
||||||
return num < 0 ? num * -1 : num;
|
return num < 0 ? num * -1 : num;
|
||||||
|
@ -17,13 +22,13 @@ public class TheManager
|
||||||
|
|
||||||
public static long getBumpValue(PostData post)
|
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)
|
public static async Task<List<PostData>> getPostList(string boardTag)
|
||||||
{
|
{
|
||||||
List<PostData> threads = await PostsRepository.getPostsByBoardAsync(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)
|
public static async Task bumpThreads(BoardData board)
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
private async Task login()
|
private async Task login()
|
||||||
{
|
{
|
||||||
Console.WriteLine("loggin you in...");
|
Console.WriteLine("loggin you in...");
|
||||||
var user = await UsersRepository.getUserByEmailAsync(Email);
|
var user = await UsersRepository.getUserByEmailRawAsync(Email);
|
||||||
if (user == null)
|
if (user == null)
|
||||||
{
|
{
|
||||||
await js.InvokeVoidAsync("alert", "User does not exist");
|
await js.InvokeVoidAsync("alert", "User does not exist");
|
||||||
|
|
|
@ -43,7 +43,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
await UsersRepository.createUserAsync(userToCreate);
|
await UsersRepository.createUserAsync(userToCreate);
|
||||||
var user = await UsersRepository.getUserByEmailAsync(Email);
|
var user = await UsersRepository.getUserByEmailRawAsync(Email);
|
||||||
if (user == null)
|
if (user == null)
|
||||||
{
|
{
|
||||||
await js.InvokeVoidAsync("alert", "User does not exist");
|
await js.InvokeVoidAsync("alert", "User does not exist");
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
|
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
|
||||||
|
|
||||||
<link rel="stylesheet" href="_content/Radzen.Blazor/css/material-dark.css">
|
<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>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
|
|
@ -153,6 +153,7 @@
|
||||||
{
|
{
|
||||||
//Open post successfull
|
//Open post successfull
|
||||||
NavigationManager.NavigateTo($"/{board.Tag}/thread/{postId}", true, true);
|
NavigationManager.NavigateTo($"/{board.Tag}/thread/{postId}", true, true);
|
||||||
|
await TheManager.bumpThreads(board);
|
||||||
Console.WriteLine("Post created");
|
Console.WriteLine("Post created");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -21,6 +21,12 @@
|
||||||
<span> </span>
|
<span> </span>
|
||||||
<span class="date"> @getTimeFromUnix(post.CreatedAt)</span>
|
<span class="date"> @getTimeFromUnix(post.CreatedAt)</span>
|
||||||
<span class="post-id">No.@post.PostID</span>
|
<span class="post-id">No.@post.PostID</span>
|
||||||
|
<AuthorizeView Roles="Admin,Mod">
|
||||||
|
<Authorized>
|
||||||
|
<span> </span>
|
||||||
|
<span>(@value)</span>
|
||||||
|
</Authorized>
|
||||||
|
</AuthorizeView>
|
||||||
</div>
|
</div>
|
||||||
@if (opened)
|
@if (opened)
|
||||||
{
|
{
|
||||||
|
@ -99,12 +105,19 @@
|
||||||
|
|
||||||
private string toggleText = "-";
|
private string toggleText = "-";
|
||||||
|
|
||||||
|
private string value;
|
||||||
|
|
||||||
private void ToggleOpened()
|
private void ToggleOpened()
|
||||||
{
|
{
|
||||||
opened = !opened;
|
opened = !opened;
|
||||||
toggleText = opened ? "-" : "+";
|
toggleText = opened ? "-" : "+";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
value = TheManager.getBumpValue(post) + "v";
|
||||||
|
}
|
||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
[Required]
|
[Required]
|
||||||
public PostData post { get; set; }
|
public PostData post { get; set; }
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
<div class="top-row ps-3 navbar navbar-dark">
|
<div class="top-row ps-3 navbar navbar-dark">
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<a class="navbar-brand" href="">ImageBoard</a>
|
<a class="navbar-brand" href="">IB v0.1.3</a>
|
||||||
<AuthorizeView>
|
<AuthorizeView>
|
||||||
<Authorized>
|
<Authorized>
|
||||||
<a class="navbar-brand" @onclick="logout" href="javascript:void(0)">[Logout]</a>
|
<a class="navbar-brand" @onclick="logout" href="javascript:void(0)">[Logout]</a>
|
||||||
|
|
Loading…
Reference in a new issue