Files
ncd-fe/src/globals.ts
marcin mikołajczak a58c52631e Arrow functions and so
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
2024-05-13 01:18:04 +02:00

26 lines
697 B
TypeScript

/**
* globals: do things through the console.
* This feature is for developers.
*/
import { changeSettingImmediate } from 'soapbox/actions/settings';
import type { Store } from 'soapbox/store';
/** Add Soapbox globals to the window. */
const createGlobals = (store: Store) => {
const Soapbox = {
/** Become a developer with `Soapbox.isDeveloper()` */
isDeveloper: (bool = true): boolean => {
if (![true, false].includes(bool)) {
throw `Invalid option ${bool}. Must be true or false.`;
}
store.dispatch(changeSettingImmediate(['isDeveloper'], bool) as any);
return bool;
},
};
(window as any).Soapbox = Soapbox;
};
export { createGlobals };