diff --git a/frontend/src/pages/sell/character-sell.tsx b/frontend/src/pages/sell/character-sell.tsx index df32b1a3f..34503d0d0 100644 --- a/frontend/src/pages/sell/character-sell.tsx +++ b/frontend/src/pages/sell/character-sell.tsx @@ -6,6 +6,7 @@ import { useMyCharacter, useSellCharacter } from "../../service"; import { Sell } from "./sell"; import { SellData } from "./types"; import { MakeOfferCallback } from "../../interfaces"; +import { useUserStateDispatch } from "../../context/user"; export const CharacterSell = () => { const { id } = useParams<"id">(); @@ -14,6 +15,7 @@ export const CharacterSell = () => { const sellCharacter = useSellCharacter(Number(idString)); const [character] = useMyCharacter(Number(idString)); const [characterCopy] = useState(character); + const userDispatch = useUserStateDispatch(); const [isPlacedInShop, setIsPlacedInShop] = useState(false); const [data, setData] = useState({ price: 0 }); @@ -23,6 +25,7 @@ export const CharacterSell = () => { // Currently calling this logic on settled due to an issue with the status returned by the sell method, // TODO: move this logic to a more specific callback setIsPlacedInShop(true); + userDispatch({ type: "SET_SELECTED", payload: "" }); }, }; diff --git a/frontend/src/service/character.ts b/frontend/src/service/character.ts index d2af6b057..4f773c50b 100644 --- a/frontend/src/service/character.ts +++ b/frontend/src/service/character.ts @@ -172,7 +172,6 @@ export const useSellCharacter = (characterId: number) => { const [service] = useAgoricContext(); const wallet = useWalletState(); const [characters] = useMyCharacters(); - const userDispatch = useUserStateDispatch(); const [isLoading, setIsLoading] = useState(false); const instance = service.contracts.kread.instance; const charBrand = service.tokenInfo.character.brand; @@ -195,10 +194,6 @@ export const useSellCharacter = (characterId: number) => { }, callback: { ...callback, - settled: () => { - if (callback.settled) callback.settled(); - userDispatch({ type: "SET_SELECTED", payload: "" }); - }, setIsLoading: setIsLoading } }); @@ -243,16 +238,6 @@ export const useBuyCharacter = (characterId: string) => { }, callback: { ...callback, - refunded: () => { - console.info("BuyCharacter call settled"); - if (callback.refunded) callback.refunded(); - setIsLoading(false); - }, - accepted: () => { - console.info("BuyCharacter call settled"); - if (callback.accepted) callback.accepted(); - setIsLoading(false); - }, setIsLoading: setIsLoading, }, }); diff --git a/frontend/src/service/items.ts b/frontend/src/service/items.ts index 436d9087a..d8ca63f9c 100644 --- a/frontend/src/service/items.ts +++ b/frontend/src/service/items.ts @@ -163,11 +163,6 @@ export const useSellItem = (itemName: string | undefined, itemCategory: Category }, callback: { ...callback, - seated: () => { - console.info("SellItem call settled"); - if (callback.seated) callback.seated(); - setIsLoading(false); - }, setIsLoading: setIsLoading } }); @@ -214,16 +209,6 @@ export const useBuyItem = (itemToBuy: ItemInMarket | undefined) => { }, callback: { ...callback, - refunded: () => { - console.info("BuyItem call settled"); - if (callback.refunded) callback.refunded(); - setIsLoading(false); - }, - accepted: () => { - console.info("BuyItem call settled"); - if (callback.accepted) callback.accepted(); - setIsLoading(false); - }, setIsLoading: setIsLoading } }); @@ -273,10 +258,6 @@ export const useEquipItem = () => { }, callback: { ...body.callback, - seated: () => { - console.info("Swap call settled"); - if (body.callback.seated) body.callback.seated(); - }, settled: () => { setTimeout(() => userStateDispatch({ type: "END_INVENTORY_CALL" }), INVENTORY_CALL_FETCH_DELAY); } @@ -294,11 +275,8 @@ export const useEquipItem = () => { }, callback: { ...body.callback, - seated: () => { - console.info("Equip call settled"); - if (body.callback.seated) body.callback.seated(); - }, settled: () => { + if (body.callback.settled) body.callback.settled(); setTimeout(() => userStateDispatch({ type: "END_INVENTORY_CALL" }), INVENTORY_CALL_FETCH_DELAY); } }, @@ -337,11 +315,8 @@ export const useUnequipItem = () => { }, callback: { ...body.callback, - seated: () => { - console.info("Unequip call settled"); - if (body.callback.seated) body.callback.seated(); - }, settled: () => { + if (body.callback.settled) body.callback.settled(); setTimeout(() => userStateDispatch({ type: "END_INVENTORY_CALL" }), INVENTORY_CALL_FETCH_DELAY); } }