Developers: become a developer through the console

draftjs
Alex Gleason 2021-11-02 11:47:26 -05:00
rodzic 0e3d27a91e
commit 860f8c3b93
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
2 zmienionych plików z 24 dodań i 0 usunięć

Wyświetl plik

@ -25,6 +25,7 @@ import { getSoapboxConfig } from 'soapbox/actions/soapbox';
import { generateThemeCss } from 'soapbox/utils/theme';
import messages from 'soapbox/locales/messages';
import { FE_SUBDIRECTORY } from 'soapbox/build_config';
import { createGlobals } from 'soapbox/globals';
const validLocale = locale => Object.keys(messages).includes(locale);
@ -33,6 +34,9 @@ const previewVideoState = 'previewVideoModal';
export const store = configureStore();
// Configure global functions for developers
createGlobals(store);
store.dispatch(preload());
store.dispatch(fetchMe())

Wyświetl plik

@ -0,0 +1,20 @@
/**
* globals: do things through the console.
* This feature is for developers.
*/
import { changeSetting } from 'soapbox/actions/settings';
export const createGlobals = store => {
const Soapbox = {
// Become a developer with `Soapbox.isDeveloper()`
isDeveloper: (bool = true) => {
if (![true, false].includes(bool)) {
throw `Invalid option ${bool}. Must be true or false.`;
}
store.dispatch(changeSetting(['isDeveloper'], bool));
return bool;
},
};
window.Soapbox = Soapbox;
};