Skip to content

Commit

Permalink
fix event and notice fetching based on selected language (#83)
Browse files Browse the repository at this point in the history
* fix: get events and notices based on language

* feat: refetch events and notices when changing language

* fix: properly set `CultureInfo` in `SetCultureInfo`
  • Loading branch information
Veirt committed Jun 22, 2024
1 parent 4efdee8 commit 53f4898
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
6 changes: 4 additions & 2 deletions MementoMori.BlazorShared/Pages/Index.razor
Original file line number Diff line number Diff line change
Expand Up @@ -465,10 +465,12 @@
}
}

protected override void OnInitialized()
protected override async Task OnInitializedAsync()
{
base.OnInitialized();
await base.OnInitializedAsync();
_ = CheckLatestVersion();

_ = Funcs.GetNoticeInfoList();
}

private void ShowNotice(NoticeInfo context)
Expand Down
7 changes: 6 additions & 1 deletion MementoMori/MementoMoriFuncs.Ops.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
using ShopGetListResponse = MementoMori.Ortega.Share.Data.ApiInterface.Shop.GetListResponse;
using TradeShopGetListRequest = MementoMori.Ortega.Share.Data.ApiInterface.TradeShop.GetListRequest;
using TradeShopGetListResponse = MementoMori.Ortega.Share.Data.ApiInterface.TradeShop.GetListResponse;
using System.Globalization;
using System.Xml.Linq;
using MementoMori.Common.Localization;
using MementoMori.MagicOnion;
Expand Down Expand Up @@ -1957,6 +1958,7 @@ public async Task GetMonthlyLoginBonusInfo()
public async Task GetNoticeInfoList()
{
var countryCode = OrtegaConst.Addressable.LanguageNameDictionary[NetworkManager.LanguageType];

var response = await GetResponse<GetNoticeInfoListRequest, GetNoticeInfoListResponse>(new GetNoticeInfoListRequest()
{
AccessType = NoticeAccessType.Title,
Expand All @@ -1974,7 +1976,10 @@ public async Task GetNoticeInfoList()
LanguageType = NetworkManager.LanguageType,
UserId = AuthOption.UserId
});
EventInfoList = response2.NoticeInfoList.Where(d=>d.Id % 10 != 6).ToList();
EventInfoList = response2.NoticeInfoList
.GroupBy(n => n.Title)
.Select(g => g.First())
.ToList();
}

public TowerType[] GetAvailableTower()
Expand Down
1 change: 1 addition & 0 deletions MementoMori/MementoNetworkManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ public async Task<bool> DownloadMasterCatalog(Action<string> log = null)

public void SetCultureInfo(CultureInfo cultureInfo)
{
CultureInfo = cultureInfo;
Masters.TextResourceTable.SetLanguageType(parseLanguageType(cultureInfo));
Masters.LoadAllMasters();
}
Expand Down

0 comments on commit 53f4898

Please sign in to comment.