pleroma/packages/pl-fe/src/globals.ts

26 lines
678 B
TypeScript
Raw Normal View History

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