-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Co-authored-by: Timmy Huang <tihuan@users.noreply.github.com>
- Loading branch information
1 parent
8098bfe
commit c19beba
Showing
3 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Core dependencies | ||
import { Intent } from "@blueprintjs/core"; | ||
import { useRouter } from "next/router"; | ||
import { useEffect } from "react"; | ||
// App dependencies | ||
import Toast from "src/views/Collection/components/Toast"; | ||
|
||
/** | ||
* Pop toast with given message if user has come from Explorer with work in progress. | ||
* @param message - Text to display in toast. | ||
*/ | ||
export function useExplainNewTab(message: string): void { | ||
const router = useRouter(); | ||
const { explainNewTab } = router.query; | ||
const { isReady } = router; | ||
|
||
/* Check for explainNewTab query string param and pop toast if present. */ | ||
useEffect(() => { | ||
// Query param with no value (e.g. explainNewTab in http://url.com/?explainNewTab) resolves to empty string. | ||
if (isReady && explainNewTab === "") { | ||
Toast.show({ | ||
intent: Intent.PRIMARY, | ||
message, | ||
}); | ||
} | ||
}, [explainNewTab, isReady, message]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters