Skip to content

Commit

Permalink
Make sure stale shop data isn't shown when opening new shop after pre…
Browse files Browse the repository at this point in the history
…vious shop has been opened
  • Loading branch information
ethanmoffat committed Apr 5, 2022
1 parent 5f4eda4 commit 89f6d9a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
6 changes: 3 additions & 3 deletions EOLib/Domain/Interact/Shop/ShopDataRepository.cs
Expand Up @@ -3,7 +3,7 @@

namespace EOLib.Domain.Interact.Shop
{
public interface IShopDataRepository
public interface IShopDataRepository : IResettable
{
int ShopID { get; set; }

Expand All @@ -14,7 +14,7 @@ public interface IShopDataRepository
List<IShopCraftItem> CraftItems { get; set; }
}

public interface IShopDataProvider
public interface IShopDataProvider : IResettable
{
int ShopID { get; }

Expand All @@ -26,7 +26,7 @@ public interface IShopDataProvider
}

[AutoMappedType(IsSingleton = true)]
public class ShopDataRepository : IShopDataProvider, IShopDataRepository, IResettable
public class ShopDataRepository : IShopDataProvider, IShopDataRepository
{
public int ShopID { get; set; }
public string ShopName { get; set; }
Expand Down
10 changes: 9 additions & 1 deletion EndlessClient/Dialogs/Actions/InGameDialogActions.cs
@@ -1,6 +1,7 @@
using AutomaticTypeMapper;
using EndlessClient.Dialogs.Factories;
using EOLib.Domain.Character;
using EOLib.Domain.Interact.Shop;
using Optional;

namespace EndlessClient.Dialogs.Actions
Expand All @@ -11,16 +12,19 @@ public class InGameDialogActions : IInGameDialogActions
private readonly IFriendIgnoreListDialogFactory _friendIgnoreListDialogFactory;
private readonly IPaperdollDialogFactory _paperdollDialogFactory;
private readonly IActiveDialogRepository _activeDialogRepository;
private readonly IShopDataRepository _shopDataRepository;
private readonly IShopDialogFactory _shopDialogFactory;

public InGameDialogActions(IFriendIgnoreListDialogFactory friendIgnoreListDialogFactory,
IPaperdollDialogFactory paperdollDialogFactory,
IActiveDialogRepository activeDialogRepository,
IShopDataRepository shopDataRepository,
IShopDialogFactory shopDialogFactory)
{
_friendIgnoreListDialogFactory = friendIgnoreListDialogFactory;
_paperdollDialogFactory = paperdollDialogFactory;
_activeDialogRepository = activeDialogRepository;
_shopDataRepository = shopDataRepository;
_shopDialogFactory = shopDialogFactory;
}

Expand Down Expand Up @@ -65,7 +69,11 @@ public void ShowShopDialog()
_activeDialogRepository.ShopDialog.MatchNone(() =>
{
var dlg = _shopDialogFactory.Create();
dlg.DialogClosed += (_, _) => _activeDialogRepository.ShopDialog = Option.None<ShopDialog>();
dlg.DialogClosed += (_, _) =>
{
_activeDialogRepository.ShopDialog = Option.None<ShopDialog>();
_shopDataRepository.ResetState();
};
_activeDialogRepository.ShopDialog = Option.Some(dlg);
dlg.Show();
Expand Down

0 comments on commit 89f6d9a

Please sign in to comment.