Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code refactor #372

Merged
merged 1 commit into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/Blogifier.Admin/Interop/CommonJsInterop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@

namespace Blogifier.Admin.Interop;

public class CommonJsInterop : IAsyncDisposable
public class CommonJsInterop(IJSRuntime jsRuntime) : IAsyncDisposable
{
private readonly Lazy<Task<IJSObjectReference>> moduleTask;

public CommonJsInterop(IJSRuntime jsRuntime) =>
moduleTask = new(() => jsRuntime.InvokeAsync<IJSObjectReference>("import", "./admin/js/common.js").AsTask());
private readonly Lazy<Task<IJSObjectReference>> moduleTask = new(() =>
jsRuntime.InvokeAsync<IJSObjectReference>("import", "./admin/js/common.js").AsTask());

public async ValueTask SetTooltipAsync()
{
Expand Down
9 changes: 2 additions & 7 deletions src/Blogifier.Shared/Models/CategoryModel.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
namespace Blogifier.Shared;

public class CategoryModel : PostPagerModel
public class CategoryModel(string category, PostPagerDto pager, MainDto main) : PostPagerModel(pager, main)
{
public string Category { get; set; }

public CategoryModel(string category, PostPagerDto pager, MainDto main) : base(pager, main)
{
Category = category;
}
public string Category { get; set; } = category;
}
5 changes: 1 addition & 4 deletions src/Blogifier.Shared/Models/IndexModel.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
using Blogifier.Shared;
namespace Blogifier.Models;

public class IndexModel : PostPagerModel
public class IndexModel(PostPagerDto pager, MainDto main) : PostPagerModel(pager, main)
{
public IndexModel(PostPagerDto pager, MainDto main) : base(pager, main)
{
}
}
9 changes: 2 additions & 7 deletions src/Blogifier.Shared/Models/MainModel.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
namespace Blogifier.Shared;

public class MainModel
public class MainModel(MainDto main)
{
public MainDto Main { get; set; }

public MainModel(MainDto main)
{
Main = main;
}
public MainDto Main { get; set; } = main;
}
11 changes: 3 additions & 8 deletions src/Blogifier.Shared/Models/PostModel.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
namespace Blogifier.Shared;

public class PostModel : MainModel
public class PostModel(PostSlugDto postSlug, string categoriesUrl, MainDto main) : MainModel(main)
{
public PostModel(PostSlugDto postSlug, string categoriesUrl, MainDto main) : base(main)
{
PostSlug = postSlug;
CategoriesUrl = categoriesUrl;
}
public PostSlugDto PostSlug { get; set; }
public string CategoriesUrl { get; set; }
public PostSlugDto PostSlug { get; set; } = postSlug;
public string CategoriesUrl { get; set; } = categoriesUrl;
}
8 changes: 2 additions & 6 deletions src/Blogifier.Shared/Models/PostPagerModel.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
namespace Blogifier.Shared;

public class PostPagerModel : MainModel
public class PostPagerModel(PostPagerDto pager, MainDto main) : MainModel(main)
{
public PostPagerModel(PostPagerDto pager, MainDto main) : base(main)
{
Pager = pager;
}
public PostPagerDto Pager { get; }
public PostPagerDto Pager { get; } = pager;
}
5 changes: 1 addition & 4 deletions src/Blogifier.Shared/Models/SearchModel.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
namespace Blogifier.Shared;

public class SearchModel : PostPagerModel
public class SearchModel(PostPagerDto pager, MainDto main) : PostPagerModel(pager, main)
{
public SearchModel(PostPagerDto pager, MainDto main) : base(pager, main)
{
}
}