Skip to content

Commit

Permalink
Fix for Dispatcher Strencher#2
Browse files Browse the repository at this point in the history
- Fix the Dispatcher, use more bespoke properties to check.
  • Loading branch information
tsukasa committed Aug 4, 2022
1 parent 21bbdb5 commit 67c874c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion dist/frontend.js

Large diffs are not rendered by default.

15 changes: 8 additions & 7 deletions frontend/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,12 @@ DOM.injectCSS("BetterDiscordWebStyles", `.CodeMirror {height: 100% !important;}`
ipcRenderer.send(IPCEvents.MAKE_REQUESTS, {
url: ENV === "development" ? "http://127.0.0.1:5500/betterdiscord.js" : "https://static.tsukasa.io/BdBrowser/dist/betterdiscord.js"
}, async bd => {
const Dispatcher = Webpack.findByProps("dispatch", "subscribe");

Logger.log("Frontend", "Dispatcher found:", Dispatcher);
const Dispatcher = Webpack.findByProps("dispatch", "subscribe", "wait", "unsubscribe");
const UserStore = Webpack.findByProps("getCurrentUser");

Logger.log("Frontend", "Dispatcher:", Dispatcher);
Logger.log("Frontend", "UserStore:", UserStore);

const callback = async () => {
Dispatcher.unsubscribe("CONNECTION_OPEN", callback);
Expand All @@ -57,12 +60,10 @@ ipcRenderer.send(IPCEvents.MAKE_REQUESTS, {
}
};

const UserStore = Webpack.findByProps("getCurrentUser");
if (!UserStore.getCurrentUser())
if (!UserStore?.getCurrentUser())
{
Logger.log("Frontend", "getCurrentUser failed.");
/* Dispatcher.subscribe("CONNECTION_OPEN", callback); */
setImmediate(callback);
Logger.log("Frontend", "getCurrentUser failed, registering callback.");
Dispatcher.subscribe("CONNECTION_OPEN", callback);
}
else
{
Expand Down

0 comments on commit 67c874c

Please sign in to comment.