Skip to content
This repository was archived by the owner on Feb 7, 2025. It is now read-only.

Commit

Permalink
feat: Add village query for temporarily
Browse files Browse the repository at this point in the history
  • Loading branch information
upa-r-upa committed Apr 6, 2024
1 parent 8a8c273 commit decd04e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
9 changes: 8 additions & 1 deletion backend/app/Savor22b/GraphTypes/Query/Query.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ namespace Savor22b.GraphTypes.Query;
using Libplanet.Net;
using Savor22b.Action;
using Savor22b.GraphTypes.Types;
using Savor22b.GraphTypes.Subscription;
using Savor22b.States;
using System.Reactive.Subjects;

public class Query : ObjectGraphType
{
Expand All @@ -22,7 +24,11 @@ public class Query : ObjectGraphType
private readonly BlockChain _blockChain;
private readonly Swarm _swarm;

public Query(BlockChain blockChain, Swarm? swarm = null)
public Query(
BlockChain blockChain,
Swarm? swarm = null,
Subject<Libplanet.Blocks.BlockHash>? subject = null
)
{
_blockChain = blockChain;
_swarm = swarm;
Expand Down Expand Up @@ -532,6 +538,7 @@ swarm is null
AddField(new CalculateRelocationCostQuery());
AddField(new DungeonReturnRewardQuery());
AddField(new ShopQuery());
AddField(new VillageField(blockChain, subject));
AddField(new ShowMeTheMoney(blockChain, swarm));
}

Expand Down
6 changes: 3 additions & 3 deletions backend/app/Savor22b/GraphTypes/Subscription/VillageField.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ namespace Savor22b.GraphTypes.Subscription;
public class VillageField : FieldType
{
private readonly BlockChain _blockChain;
private readonly Subject<Libplanet.Blocks.BlockHash> _subject;
private readonly Subject<Libplanet.Blocks.BlockHash>? _subject;

public VillageField(BlockChain blockChain, Subject<Libplanet.Blocks.BlockHash> subject)
public VillageField(BlockChain blockChain, Subject<Libplanet.Blocks.BlockHash>? subject = null)
: base()
{
_blockChain = blockChain;
Expand Down Expand Up @@ -53,7 +53,7 @@ public VillageField(BlockChain blockChain, Subject<Libplanet.Blocks.BlockHash> s
{
var villages = CsvDataHelper.GetVillageCSVData().ToArray();

return _subject
return _subject!
.DistinctUntilChanged()
.Select(
_ => GetVillageDetails(villages.ToImmutableList(), context, blockChain)
Expand Down

0 comments on commit decd04e

Please sign in to comment.