Skip to content

Commit

Permalink
Merge pull request #372 from KhanbalaRashidov/main
Browse files Browse the repository at this point in the history
Code refactor
  • Loading branch information
dorthl authored Jul 15, 2024
2 parents 75b6063 + 4e33ae8 commit 2d8fd52
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 41 deletions.
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)
{
}
}

0 comments on commit 2d8fd52

Please sign in to comment.