add a setting to show all flux dispatcher payloads in console

pull/95/head
dperolio 2 years ago
parent c80538d7da
commit f90ebe418d
No known key found for this signature in database
GPG Key ID: 4191689562D51409

@ -1,5 +1,7 @@
import { log, warn, error } from '@vizality/util/logger';
/**
*
*
*/
import { FluxDispatcher } from '@vizality/webpack';
@ -10,6 +12,9 @@ export default main => {
const ogDispatch = FluxDispatcher.dispatch;
try {
FluxDispatcher.dispatch = function (args) {
if (vizality.settings.get('fluxDispatcherLogs', false)) {
vizality.log(vizality._labels.concat('Dispatcher'), args);
}
this.wait(() => this._dispatch(args));
};
} catch (err) {

@ -5,6 +5,7 @@ import { Messages } from '@vizality/i18n';
export default memo(({ builtin, search = '' }) => {
const [ reactDeveloperTools, setReactDeveloperTools ] = vizality.api.settings.useSetting('reactDeveloperTools', false);
const [ fluxDispatcherLogs, setFluxDispatcherLogs ] = vizality.api.settings.useSetting('fluxDispatcherLogs', false);
const [ hotReload, setHotReload ] = vizality.api.settings.useSetting('hotReload', false);
const items = [
@ -24,6 +25,27 @@ export default memo(({ builtin, search = '' }) => {
{Messages.VIZALITY_SETTINGS_REACT_DEVELOPER_TOOLS}
</SwitchItem>
},
{
search: [
Messages.VIZALITY_SETTINGS_LOG_FLUX_DISPATCHER_PAYLOADS,
Messages.VIZALITY_SETTINGS_LOG_FLUX_DISPATCHER_PAYLOADS_DESC
],
render: query =>
<SwitchItem
description={Messages.VIZALITY_SETTINGS_LOG_FLUX_DISPATCHER_PAYLOADS_DESC}
value={fluxDispatcherLogs}
onChange={() => {
try {
setFluxDispatcherLogs(!fluxDispatcherLogs);
} catch (err) {
builtin.error(err);
}
}}
info={Messages.VIZALITY_SETTINGS_LOG_FLUX_DISPATCHER_PAYLOADS_INFO}
>
{Messages.VIZALITY_SETTINGS_LOG_FLUX_DISPATCHER_PAYLOADS}
</SwitchItem>
},
{
search: [
Messages.VIZALITY_SETTINGS_PLUGIN_HOT_RELOAD,

@ -9,6 +9,7 @@ import { log as _log, warn as _warn, error as _error } from '@vizality/util/logg
import { Directories, Developers, Events, Protocols } from '@vizality/constants';
import { resolveCompiler } from '@vizality/compilers';
import { createElement } from '@vizality/util/dom';
import { isArray } from '@vizality/util/array';
import { Updatable } from '@vizality/entities';
import { debounce } from 'lodash';
import { promisify } from 'util';
@ -436,28 +437,43 @@ export default class Vizality extends Updatable {
/**
*
* @param {...any} message
* @param {any} message Message to log
* @returns {void}
*/
log (...message) {
// In case the addon wants to provide their own labels
if (isArray(message[0])) {
const _message = message.slice(1);
return _log({ labels: message[0], message: _message });
}
return _log({ labels: this._labels, message });
}
/**
*
* @param {...any} message
* @param {any} message Message to log
* @returns {void}
*/
warn (...message) {
// In case the addon wants to provide their own labels
if (isArray(message[0])) {
const _message = message.slice(1);
return _warn({ labels: message[0], message: _message });
}
return _warn({ labels: this._labels, message });
}
/**
*
* @param {...any} message
* @param {any} message Message to log
* @returns {void}
*/
error (...message) {
// In case the addon wants to provide their own labels
if (isArray(message[0])) {
const _message = message.slice(1);
return _error({ labels: message[0], message: _message });
}
return _error({ labels: this._labels, message });
}
}

@ -73,6 +73,9 @@
"VIZALITY_SETTINGS_REACT_DEVELOPER_TOOLS": "React Developer Tools",
"VIZALITY_SETTINGS_REACT_DEVELOPER_TOOLS_DESC": "Enables the React Developer Tools extension.",
"VIZALITY_SETTINGS_REACT_DEVELOPER_TOOLS_INFO": "This can and will increase CPU usage and cause performance drops over time. It is recommended to only be kept on while actively developing.",
"VIZALITY_SETTINGS_LOG_FLUX_DISPATCHER_PAYLOADS": "Log Flux Dispatcher Payloads to Console",
"VIZALITY_SETTINGS_LOG_FLUX_DISPATCHER_PAYLOADS_DESC": "Logs all registered dispatches to Developer Tools console. This can be very useful in identifying payload arguments, dispatch types, and expected argument values. ",
"VIZALITY_SETTINGS_LOG_FLUX_DISPATCHER_PAYLOADS_INFO": "This will spam your console, logging most actions in Discord. This should only be enabled while actively using it for development, otherwise you may notice performance drops.",
"VIZALITY_SETTINGS_PLUGIN_HOT_RELOAD": "Plugin Hot Reload",
"VIZALITY_SETTINGS_PLUGIN_HOT_RELOAD_DESC": "Enables automatic hot reloading of plugins when folder and file changes occur.",
"VIZALITY_SNIPPET_APPLIED": "Remove Snippet",

Loading…
Cancel
Save