Skip to content

Commit

Permalink
feat: revert and expose updater functions
Browse files Browse the repository at this point in the history
  • Loading branch information
rxri committed Dec 7, 2023
1 parent 28c33e3 commit 24a3f7e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
4 changes: 2 additions & 2 deletions jsHelper/spicetifyWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,8 @@ window.Spicetify = {
},
ReactComponent: {},
ReactHook: {},
ReactFlipToolkit: {}
ReactFlipToolkit: {},
Snackbar: {}
};

(async function hotloadWebpackModules() {
Expand Down Expand Up @@ -449,7 +450,6 @@ 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+\)\}/))
},
Expand Down
14 changes: 12 additions & 2 deletions src/preprocess/preprocess.go
Original file line number Diff line number Diff line change
Expand Up @@ -465,8 +465,18 @@ 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=${0}`)
`\(\w+\s*=\s*\w\.call\(this,[^)]+\)\s*\|\|\s*this\)\.enqueueSnackbar`,
` Spicetify.Snackbar.enqueueSnackbar=${0}`)

utils.Replace(
&input,
`\w+.closeSnackbar=function`,
`Spicetify.Snackbar.closeSnackbar=${0}`)

utils.Replace(
&input,
`(this\.updater)\s*=\s*(.*)`,
`${1}=Spicetify.Snackbar.updater=${2}`)

return input
}
Expand Down

0 comments on commit 24a3f7e

Please sign in to comment.