diff --git a/jsHelper/spicetifyWrapper.js b/jsHelper/spicetifyWrapper.js index b6419e156f..7fe0110d20 100644 --- a/jsHelper/spicetifyWrapper.js +++ b/jsHelper/spicetifyWrapper.js @@ -311,7 +311,8 @@ window.Spicetify = { }, ReactComponent: {}, ReactHook: {}, - ReactFlipToolkit: {} + ReactFlipToolkit: {}, + Snackbar: {} }; (async function hotloadWebpackModules() { @@ -449,6 +450,7 @@ window.Spicetify = { // Snackbar notifications // https://github.com/iamhosseindhv/notistack Snackbar: { + ...Spicetify.Snackbar, SnackbarProvider: functionModules.find(m => m.toString().includes("enqueueSnackbar called with invalid argument")), useSnackbar: functionModules.find(m => m.toString().match(/\{return\(0,\w+\.useContext\)\(\w+\)\}/)) }, @@ -542,7 +544,6 @@ window.Spicetify = { return; } - if (!Spicetify.Snackbar) Spicetify.Snackbar = {}; Spicetify.Snackbar.enqueueSnackbar = (message, { variant = "default", autoHideDuration } = {}) => { isError = variant === "error"; Spicetify.showNotification(message, isError, autoHideDuration); diff --git a/src/preprocess/preprocess.go b/src/preprocess/preprocess.go index 3c0a920c3b..7a8f63d472 100644 --- a/src/preprocess/preprocess.go +++ b/src/preprocess/preprocess.go @@ -465,13 +465,8 @@ if (${1}.popper?.firstChild?.id === "context-menu") { // Snackbar https://github.com/iamhosseindhv/notistack utils.Replace( &input, - `\(\w+\s*=\s*\w\.call\(this,[^)]+\)\s*\|\|\s*this\)\.enqueueSnackbar`, - ` Spicetify.Snackbar.enqueueSnackbar=${0}`) - - utils.Replace( - &input, - `\w+.closeSnackbar=function`, - `Spicetify.Snackbar.closeSnackbar=${0}`) + `\w+\s*=\s*\w\.call\(this,[^)]+\)\s*\|\|\s*this\)\.enqueueSnackbar`, + `Spicetify.Snackbar=${0}`) return input }