mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-08-09 05:18:47 +00:00
Fix news summary on LBP2
This commit is contained in:
parent
c1d932d4de
commit
7b6786ce87
2 changed files with 9 additions and 7 deletions
|
@ -76,6 +76,12 @@ public class GameStream : ILbpSerializable, INeedsPreparationForSerialization
|
||||||
|
|
||||||
public async Task PrepareSerialization(DatabaseContext database)
|
public async Task PrepareSerialization(DatabaseContext database)
|
||||||
{
|
{
|
||||||
|
this.Slots = await LoadEntities<SlotEntity, SlotBase>(this.SlotIds, slot => SlotBase.CreateFromEntity(slot, this.TargetGame, this.TargetUserId));
|
||||||
|
this.Users = await LoadEntities<UserEntity, GameUser>(this.UserIds, user => GameUser.CreateFromEntity(user, this.TargetGame));
|
||||||
|
this.Playlists = await LoadEntities<PlaylistEntity, GamePlaylist>(this.PlaylistIds, GamePlaylist.CreateFromEntity);
|
||||||
|
this.News = await LoadEntities<WebsiteAnnouncementEntity, GameNewsObject>(this.NewsIds, a => GameNewsObject.CreateFromEntity(a, this.TargetGame));
|
||||||
|
return;
|
||||||
|
|
||||||
async Task<List<TResult>> LoadEntities<TFrom, TResult>(List<int> ids, Func<TFrom, TResult> transformation)
|
async Task<List<TResult>> LoadEntities<TFrom, TResult>(List<int> ids, Func<TFrom, TResult> transformation)
|
||||||
where TFrom : class
|
where TFrom : class
|
||||||
{
|
{
|
||||||
|
@ -91,11 +97,6 @@ public class GameStream : ILbpSerializable, INeedsPreparationForSerialization
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.Slots = await LoadEntities<SlotEntity, SlotBase>(this.SlotIds, slot => SlotBase.CreateFromEntity(slot, this.TargetGame, this.TargetUserId));
|
|
||||||
this.Users = await LoadEntities<UserEntity, GameUser>(this.UserIds, user => GameUser.CreateFromEntity(user, this.TargetGame));
|
|
||||||
this.Playlists = await LoadEntities<PlaylistEntity, GamePlaylist>(this.PlaylistIds, GamePlaylist.CreateFromEntity);
|
|
||||||
this.News = await LoadEntities<WebsiteAnnouncementEntity, GameNewsObject>(this.NewsIds, GameNewsObject.CreateFromEntity);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GameStream CreateFromGroups
|
public static GameStream CreateFromGroups
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
using System.Xml.Serialization;
|
using System.Xml.Serialization;
|
||||||
using LBPUnion.ProjectLighthouse.Extensions;
|
using LBPUnion.ProjectLighthouse.Extensions;
|
||||||
using LBPUnion.ProjectLighthouse.Types.Entities.Website;
|
using LBPUnion.ProjectLighthouse.Types.Entities.Website;
|
||||||
|
using LBPUnion.ProjectLighthouse.Types.Users;
|
||||||
|
|
||||||
namespace LBPUnion.ProjectLighthouse.Types.Serialization.News;
|
namespace LBPUnion.ProjectLighthouse.Types.Serialization.News;
|
||||||
|
|
||||||
|
@ -33,12 +34,12 @@ public class GameNewsObject : ILbpSerializable
|
||||||
[XmlElement("category")]
|
[XmlElement("category")]
|
||||||
public string Category { get; set; }
|
public string Category { get; set; }
|
||||||
|
|
||||||
public static GameNewsObject CreateFromEntity(WebsiteAnnouncementEntity entity) =>
|
public static GameNewsObject CreateFromEntity(WebsiteAnnouncementEntity entity, GameVersion gameVersion) =>
|
||||||
new()
|
new()
|
||||||
{
|
{
|
||||||
Id = entity.AnnouncementId,
|
Id = entity.AnnouncementId,
|
||||||
Title = entity.Title,
|
Title = entity.Title,
|
||||||
Summary = "",
|
Summary = gameVersion == GameVersion.LittleBigPlanet2 ? entity.Content : "",
|
||||||
Text = entity.Content,
|
Text = entity.Content,
|
||||||
Category = "no_category",
|
Category = "no_category",
|
||||||
Timestamp = entity.PublishedAt.ToUnixTimeMilliseconds(),
|
Timestamp = entity.PublishedAt.ToUnixTimeMilliseconds(),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue