From fcd11d0911a4919802b5a6e156e732e916ab0b02 Mon Sep 17 00:00:00 2001 From: Grigory Date: Mon, 18 Dec 2023 03:16:55 +0500 Subject: [PATCH] fix(wrapper): wait for snackbar exposition --- jsHelper/spicetifyWrapper.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/jsHelper/spicetifyWrapper.js b/jsHelper/spicetifyWrapper.js index 59b9f197a0..9f341e658c 100644 --- a/jsHelper/spicetifyWrapper.js +++ b/jsHelper/spicetifyWrapper.js @@ -449,15 +449,22 @@ window.Spicetify = { }, _reservedPanelIds: modules.find(m => m?.BuddyFeed), Mousetrap: cache.find(m => m?.addKeycodes), + Locale: modules.find(m => m?._dictionary) + }); + + (function waitForSnackbar() { + if (!Object.keys(Spicetify.Snackbar).length) { + setTimeout(waitForSnackbar, 100); + return; + } // Snackbar notifications // https://github.com/iamhosseindhv/notistack - Snackbar: { + Spicetify.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+\)\}/)) - }, - Locale: modules.find(m => m?._dictionary) - }); + }; + })(); const localeModule = modules.find(m => m?.getTranslations); if (localeModule) {