Skip to content

Commit

Permalink
Rename Page -> WallPage
Browse files Browse the repository at this point in the history
  • Loading branch information
electroly committed Nov 19, 2024
1 parent 6ad37c1 commit fa084bb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
22 changes: 11 additions & 11 deletions src/J.Server/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
var password = accountSettings.Password ?? throw new Exception("Encryption key not found.");

var preferences = app.Services.GetRequiredService<Preferences>();
Dictionary<ListPageKey, Lazy<Page>> listPages = [];
Dictionary<TagId, Lazy<Page>> tagPages = [];
Dictionary<ListPageKey, Lazy<WallPage>> listPages = [];
Dictionary<TagId, Lazy<WallPage>> tagPages = [];

void RefreshLibrary()
{
Expand All @@ -50,7 +50,7 @@ void RefreshLibrary()

// List pages
{
Dictionary<ListPageKey, Lazy<Page>> dict = [];
Dictionary<ListPageKey, Lazy<WallPage>> dict = [];
dict[new ListPageKey(ListPageType.Movies, null)] = new(
() => NewPageFromMovies(movies, libraryMetadata, sortOrder, "Movies")
);
Expand All @@ -66,7 +66,7 @@ void RefreshLibrary()

// Individual tag pages
{
Dictionary<TagId, Lazy<Page>> dict = [];
Dictionary<TagId, Lazy<WallPage>> dict = [];
var movieIds = movies.Select(x => x.Id).ToHashSet();
foreach (var tag in libraryProvider.GetTags())
dict[tag.Id] = new(
Expand Down Expand Up @@ -155,7 +155,7 @@ void Add(bool x)
}
}

static Page GetTagListPage(
static WallPage GetTagListPage(
LibraryProvider libraryProvider,
TagType tagType,
SortOrder sortOrder,
Expand All @@ -164,19 +164,19 @@ LibraryMetadata libraryMetadata
{
var tags = libraryProvider.GetTags(tagType.Id);
var dict = libraryProvider.GetRandomMoviePerTag(tagType);
List<Page.Block> blocks = [];
List<WallPage.Block> blocks = [];
foreach (var tag in tags)
{
if (!dict.TryGetValue(tag.Id, out var movieId))
continue;

Page.Block block = new(movieId, tag.Id, tag.Name, DateTimeOffset.Now, []);
WallPage.Block block = new(movieId, tag.Id, tag.Name, DateTimeOffset.Now, []);
blocks.Add(block);
}
return NewPageFromBlocks(blocks, sortOrder, tagType.PluralName);
}

static string GetField(Page.Block block, string field)
static string GetField(WallPage.Block block, string field)
{
if (field == "name")
return block.Title;
Expand All @@ -190,7 +190,7 @@ static string GetField(Page.Block block, string field)
return "";
}

static Page NewPageFromBlocks(List<Page.Block> blocks, SortOrder sortOrder, string title)
static WallPage NewPageFromBlocks(List<WallPage.Block> blocks, SortOrder sortOrder, string title)
{
if (sortOrder.Shuffle)
{
Expand Down Expand Up @@ -239,7 +239,7 @@ static Dictionary<TagTypeId, string> GetSortTags(Movie movie, LibraryMetadata li
.ToDictionary(x => x.Key, x => x.Min(x => x.Name)!);
}

static Page NewPageFromMovies(
static WallPage NewPageFromMovies(
IEnumerable<Movie> movies,
LibraryMetadata libraryMetadata,
SortOrder sortOrder,
Expand All @@ -249,7 +249,7 @@ string title
return NewPageFromBlocks(
(
from x in movies
select new Page.Block(x.Id, null, x.Filename, x.DateAdded, GetSortTags(x, libraryMetadata))
select new WallPage.Block(x.Id, null, x.Filename, x.DateAdded, GetSortTags(x, libraryMetadata))
).ToList(),
sortOrder,
title
Expand Down
2 changes: 1 addition & 1 deletion src/J.Server/Page.cs → src/J.Server/WallPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace J.Server;

public readonly record struct Page(List<Page.Block> Blocks, string Title)
public readonly record struct WallPage(List<WallPage.Block> Blocks, string Title)
{
public readonly record struct Block(
MovieId MovieId, // movie to get the clip from
Expand Down

0 comments on commit fa084bb

Please sign in to comment.