diff --git a/src/components/stash-view/exporters/stash-view-generic-tft-exporter-card.tsx b/src/components/stash-view/exporters/stash-view-generic-tft-exporter-card.tsx index 8320bb7..25a003f 100644 --- a/src/components/stash-view/exporters/stash-view-generic-tft-exporter-card.tsx +++ b/src/components/stash-view/exporters/stash-view-generic-tft-exporter-card.tsx @@ -10,6 +10,7 @@ import { useStashViewContext } from "@contexts/stash-view-context"; import { usePoeStackAuth } from "@contexts/user-context"; import { GeneralUtils } from "@utils/general-util"; import { TFT_CATEGORIES } from "@utils/tft-categories"; +import { useMessagePostedContext } from "@contexts/post-message-events-context"; export function StashViewGenericTftExporterCard() { const { profile } = usePoeStackAuth(); @@ -18,6 +19,8 @@ export function StashViewGenericTftExporterCard() { const [error, setError] = useState(null); const [statusText, setStatusText] = useState(null); + const { setMessagePosted } = useMessagePostedContext(); + function generateInput() { return { league: stashViewSettings.league, @@ -55,6 +58,7 @@ export function StashViewGenericTftExporterCard() { onCompleted() { setError(null); setStatusText(null); + setMessagePosted(true); }, onError(error) { setError(error.message); diff --git a/src/components/tft-oneclick-message-history-card.tsx b/src/components/tft-oneclick-message-history-card.tsx index 522d70a..76a5bdf 100644 --- a/src/components/tft-oneclick-message-history-card.tsx +++ b/src/components/tft-oneclick-message-history-card.tsx @@ -1,11 +1,13 @@ -import { useEffect, useState } from "react"; +import { useContext, useEffect, useState } from "react"; import { gql, useLazyQuery, useMutation, useQuery } from "@apollo/client"; import { OneClickMessageHistory } from "@generated/graphql"; import StyledButton from "./library/styled-button"; +import { useMessagePostedContext } from "@contexts/post-message-events-context"; export default function TftOneClickMessageHistoryCard() { + const { messagePosted, setMessagePosted } = useMessagePostedContext(); const [messages, setMessages] = useState( null ); @@ -31,6 +33,12 @@ export default function TftOneClickMessageHistoryCard() { } ); + useEffect(() => { + if (messagePosted) { + fetch().finally(() => setMessagePosted(false)); + } + }, [messagePosted, setMessagePosted, fetch]) + const [deleteMessage] = useMutation( gql` mutation DeleteTftOneClickMessage($messageId: String!) { diff --git a/src/contexts/post-message-events-context.tsx b/src/contexts/post-message-events-context.tsx new file mode 100644 index 0000000..fc01076 --- /dev/null +++ b/src/contexts/post-message-events-context.tsx @@ -0,0 +1,23 @@ +import { createContext, useContext, useEffect, useState } from "react"; + +const initalContext: { + messagePosted: boolean; + setMessagePosted: (messagePosted: boolean) => void; +} = { + messagePosted: false, + setMessagePosted: (messagePosted: boolean) => {}, +}; + +export const MessagePostedContext = createContext(initalContext); + +export function MessagePostedProvider({ children }) { + const [messagePosted, setMessagePosted] = useState(false); + + return ( + + {children} + + ); +} + +export const useMessagePostedContext = () => useContext(MessagePostedContext); diff --git a/src/pages/tft/bulk-tool.tsx b/src/pages/tft/bulk-tool.tsx index 1b95ef3..463aa6e 100644 --- a/src/pages/tft/bulk-tool.tsx +++ b/src/pages/tft/bulk-tool.tsx @@ -11,6 +11,8 @@ import { StashViewContextProvider } from "@contexts/stash-view-context"; import { usePoeStackAuth } from "@contexts/user-context"; import TftGuardPanel from "../../components/item-table/tft-guard-panel"; +import { createContext, useState } from "react"; +import { MessagePostedProvider } from "@contexts/post-message-events-context"; export default function BulkTool() { const router = useRouter(); @@ -26,34 +28,36 @@ export default function BulkTool() {
- - - - - - - - - - -
-
Settings (Optional)
-
- {profile?.discordUsername ? `Current Discord: {${profile?.discordUsername}} (${profile?.discordUserId})` : `Discord account not connected yet`} + + + + + + + + + + + +
+
Settings (Optional)
+
+ {profile?.discordUsername ? `Current Discord: {${profile?.discordUsername}} (${profile?.discordUserId})` : `Discord account not connected yet`} +
+ { + localStorage.setItem("variable-redirect", router.asPath); + router.push( + "https://discord.com/api/oauth2/authorize?client_id=1075074940275019836&redirect_uri=https%3A%2F%2Fpoestack.com%2Fdiscord%2Fconnected&response_type=code&scope=identify" + ); + }} + />
- { - localStorage.setItem("variable-redirect", router.asPath); - router.push( - "https://discord.com/api/oauth2/authorize?client_id=1075074940275019836&redirect_uri=https%3A%2F%2Fpoestack.com%2Fdiscord%2Fconnected&response_type=code&scope=identify" - ); - }} - /> -
- + +