misc code cleanup and fixes

pull/67/head
dperolio 3 years ago
parent bf7d40fe23
commit ff6bf70ddb
No known key found for this signature in database
GPG Key ID: 3E9BBAA710D3DDCE

@ -84,7 +84,7 @@
font-size: 10px;
padding: 2px 6px;
}
&.test {
&[vz-collapsed] {
height: 50px !important;
width: 50px;
border-radius: 8px;

@ -9,6 +9,9 @@
display: flex;
flex-direction: column;
flex: 1;
> :first-child {
margin-top: 0;
}
}
& + & {
margin-top: 40px;

@ -1,179 +0,0 @@
import React, { memo, useState } from 'react';
import { TextInput, SwitchItem, ButtonItem, Category } from '@vizality/components/settings';
import { removeDirRecursive } from '@vizality/util/file';
import { Directories } from '@vizality/constants';
import { getModule } from '@vizality/webpack';
import { Icon } from '@vizality/components';
import { Messages } from '@vizality/i18n';
export default memo(({ getSetting, toggleSetting, updateSetting }) => {
const [ isDiscordCacheCleared, setDiscordCacheCleared ] = useState(false);
const [ isVizalityCacheCleared, setVizalityCacheCleared ] = useState(false);
const clearDiscordCache = () => {
setDiscordCacheCleared(true);
vizality.native.app.clearCache().then(() => {
setTimeout(() => {
setDiscordCacheCleared(false);
}, 2500);
});
};
const clearVizalityCache = () => {
setVizalityCacheCleared(true);
removeDirRecursive(Directories.CACHE).then(() => {
setTimeout(() => {
setVizalityCacheCleared(false);
}, 2500);
});
};
return (
<div>
<TextInput
defaultValue={getSetting('commandPrefix', '.')}
onChange={p => updateSetting('commandPrefix', !p ? '.' : p.replace(/\s+(?=\S)|(?<=\s)\s+/g, '').toLowerCase())}
onBlur={({ target }) => target.value = getSetting('commandPrefix', '.')}
error={getSetting('commandPrefix', '.') === '/' ? 'Prefix should not be set to `/` as it is already in use by Discord and may disable Vizality autocompletions.' : ''}
>
{Messages.VIZALITY_COMMAND_PREFIX}
</TextInput>
<SwitchItem
note={Messages.VIZALITY_SETTINGS_NO_CLYDE_DESC.format({ discordiaUrl: 'https://discordia.me/clyde', apiUrl: `${window.location.origin}/vizality/docs` })}
value={getSetting('replaceClyde', true)}
onChange={() => {
try {
toggleSetting('replaceClyde', true);
} catch (err) {
console.log(err);
}
}}
>
<Icon
className='vz-settings-eradicate-clyde-icon-wrapper'
iconClassName='vz-settings-eradicate-clyde-icon'
name='Robot'
size='20px'
/>
{Messages.VIZALITY_SETTINGS_NO_CLYDE}
</SwitchItem>
<SwitchItem
note={Messages.VIZALITY_SETTINGS_SMOOTH_SCROLLING_DESC.format()}
value={getSetting('smoothScrolling', true)}
onChange={() => {
toggleSetting('smoothScrolling', true);
vizality.api.actions.invokeAction('CONFIRM_RESTART');
}}
>
{Messages.VIZALITY_SETTINGS_SMOOTH_SCROLLING}
</SwitchItem>
<Category
name={Messages.ADVANCED_SETTINGS}
description={Messages.VIZALITY_SETTINGS_ADVANCED_DESC}
opened={getSetting('advancedSettings', false)}
onChange={() => toggleSetting('advancedSettings')}
>
<SwitchItem
note={Messages.VIZALITY_SETTINGS_REACT_DEVELOPER_TOOLS_DESC.format()}
value={getSetting('reactDeveloperTools', false)}
onChange={() => {
toggleSetting('reactDeveloperTools', false);
vizality.api.actions.invokeAction('CONFIRM_RESTART');
}}
>
{Messages.VIZALITY_SETTINGS_REACT_DEVELOPER_TOOLS}
</SwitchItem>
<SwitchItem
note='Enables live reload for folder/file changes for plugins.'
value={getSetting('hotReload', false)}
onChange={async () => {
toggleSetting('hotReload', false);
await vizality.manager.plugins.remountAll();
}}
>
Enable Hot Reload
</SwitchItem>
{/* <SwitchItem
note={Messages.VIZALITY_SETTINGS_DEBUG_LOGS_DESC}
value={getSetting('debugLogs', false)}
onChange={() => {
toggleSetting('debugLogs');
confirmRestart();
}}
>
{Messages.VIZALITY_SETTINGS_DEBUG_LOGS}
</SwitchItem> */}
{/* <SwitchItem
note={'Vizality\'s Software Development Kit (SDK) is a toolkit created to help make plugin developers\'s and theme developers\' lives easier. Once enabled, you can access it through an icon at the top right hand corner of the channel headerbar.'}
value={getSetting('sdkEnabled', false)}
onChange={() => toggleSetting('sdkEnabled')}
>
Enable Software Development Kit
</SwitchItem>
<SwitchItem
note={Messages.VIZALITY_SETTINGS_OVERLAY_DESC}
value={getSetting('openOverlayDevTools', false)}
onChange={() => toggleSetting('openOverlayDevTools')}
>
{Messages.VIZALITY_SETTINGS_OVERLAY}
</SwitchItem> */}
<SwitchItem
note={Messages.VIZALITY_SETTINGS_KEEP_TOKEN_DESC}
value={getSetting('hideToken', true)}
onChange={() => toggleSetting('hideToken', true)}
>
{Messages.VIZALITY_SETTINGS_KEEP_TOKEN}
</SwitchItem>
<SwitchItem
note={Messages.VIZALITY_SETTINGS_TRANSPARENT_DESC.format()}
value={getSetting('transparentWindow', false)}
onChange={() => {
toggleSetting('transparentWindow');
vizality.api.actions.invokeAction('CONFIRM_RESTART');
}}
>
{Messages.VIZALITY_SETTINGS_TRANSPARENT}
</SwitchItem>
<SwitchItem
note={Messages.VIZALITY_SETTINGS_EXP_WEB_PLATFORM_DESC.format()}
value={getSetting('experimentalWebPlatform', false)}
onChange={() => {
toggleSetting('experimentalWebPlatform');
vizality.api.actions.invokeAction('CONFIRM_RESTART');
}}
>
{Messages.VIZALITY_SETTINGS_EXP_WEB_PLATFORM}
</SwitchItem>
<SwitchItem
note={Messages.VIZALITY_SETTINGS_DISCORD_EXPERIMENTS_DESC.format()}
value={getSetting('experiments', false)}
onChange={() => {
toggleSetting('experiments');
// Update modules
const experimentsModule = getModule(r => r.isDeveloper !== void 0);
experimentsModule._changeCallbacks.forEach(cb => cb());
}}
>
{Messages.VIZALITY_SETTINGS_DISCORD_EXPERIMENTS}
</SwitchItem>
</Category>
<ButtonItem
note={Messages.VIZALITY_SETTINGS_CACHE_VIZALITY_DESC}
button={isVizalityCacheCleared ? Messages.VIZALITY_SETTINGS_CACHE_CLEARED : Messages.VIZALITY_SETTINGS_CACHE_VIZALITY}
success={isVizalityCacheCleared}
onClick={() => clearVizalityCache()}
>
{Messages.VIZALITY_SETTINGS_CACHE_VIZALITY}
</ButtonItem>
<ButtonItem
note={Messages.VIZALITY_SETTINGS_CACHE_DISCORD_DESC}
button={isDiscordCacheCleared ? Messages.VIZALITY_SETTINGS_CACHE_CLEARED : Messages.VIZALITY_SETTINGS_CACHE_DISCORD}
success={isDiscordCacheCleared}
onClick={() => clearDiscordCache()}
>
{Messages.VIZALITY_SETTINGS_CACHE_DISCORD}
</ButtonItem>
</div>
);
});

@ -13,7 +13,7 @@
display: flex;
flex-direction: column;
flex: 1;
margin: 10px 0;
margin: 0 0 10px;
}
.vz-quick-code-tab-bar {
@ -22,7 +22,5 @@
height: 50px;
border-radius: 8px 8px 0 0;
flex: 1 0 auto;
border-bottom: none;
box-sizing: border-box;
border-bottom: 1px solid var(--background-tertiary);
}

@ -8,6 +8,7 @@ import Events from 'events';
*/
export default class CommunityManager extends Events {
constructor () {
super();
this.plugins = new Map();
this.themes = new Map();
}

@ -10,26 +10,10 @@ import React, { memo } from 'react';
* @returns {React.MemoExoticComponent<function(): React.ReactElement>}
*/
export default memo(({ type, children, className }) => {
const { side, top, topPill } = getModule('selected', 'item', 'topPill');
const { topPill } = getModule('selected', 'item', 'topPill');
const { tabBar } = getModule('tabBar', 'item');
/**
* Check if type prop matches one of the available types, if it doesn't, set it
* to topPill by default.
*/
switch (type) {
case side:
case 'side':
type = side; break;
case top:
case 'top':
type = top; break;
case topPill:
case 'top-pill':
type = topPill; break;
default:
type = topPill;
}
type = type || topPill;
return (
<AnimateSharedLayout>

@ -206,7 +206,7 @@ const StickyBar = memo(({ query, type, tab, resetSearchOptions, handleTabChange,
wrapperClassName='vz-addons-list-sticky-bar-wrapper'
className='vz-addons-list-sticky-bar'
>
<__TabBar type='top-pill'>
<__TabBar type={__TabBar.Types.TOP_PILL}>
<__TabBar.NavItem
route={`/vizality/${toPlural(type)}/installed`}
selected={tab === 'installed'}

@ -17,7 +17,9 @@ export default memo(({ header, collapsed, onToggle, side = 'right', children, cl
const { header: headerClass } = getModule('header', 'separator', 'side', 'top');
return (
<div
className={joinClassNames('vz-dashboard-content-sidebar', className, { test: _collapsed })}
className={joinClassNames('vz-dashboard-content-sidebar', className)}
vz-collapsed={Boolean(_collapsed) && ''}
vz-expanded={Boolean(!_collapsed) && ''}
>
<Tooltip text={_collapsed ? 'Expand' : 'Collapse'}>
<div

@ -10,14 +10,15 @@ import React, { memo } from 'react';
* @param {string|React.Component|function(): React.ReactElement} [description] Section description
* @returns {React.MemoExoticComponent<function(): React.ReactElement>}
*/
export const Header = memo(({ icon, header, description, separator }) => {
export const Header = memo(({ icon, header, description, separator, collapsible }) => {
const { headerSubtext } = getModule('headerSubtext');
const { marginBottom40 } = getModule('marginBottom40');
const { content } = getModule('wrappedLayout');
const { h1 } = getModule('h1', 'h2', 'h3');
const { size24 } = getModule('size24');
const { base } = getModule('base');
return (
<div className={joinClassNames('vz-dashboard-section-header-wrapper')}>
<div className={joinClassNames('vz-dashboard-section-header-wrapper', { [marginBottom40]: !collapsible })}>
<div className='vz-dashboard-content-header-inner-wrapper'>
{icon && (
<Icon
@ -52,11 +53,11 @@ export const Header = memo(({ icon, header, description, separator }) => {
* @param {...any} [children] Section children
* @returns {React.MemoExoticComponent<function(): React.ReactElement>}
*/
export default memo(({ header, description, icon, separator = true, collapsible = false, className, children }) => {
export default memo(({ header, description, icon, separator = true, collapsible = false, id, className, children }) => {
return (
<div className={joinClassNames('vz-dashboard-section', className)} vz-collapsible={collapsible && ''}>
<div className={joinClassNames('vz-dashboard-section', className)} vz-collapsible={collapsible && ''} id={id}>
{header && (
<Header header={header} description={description} icon={icon} separator={separator} />
<Header header={header} description={description} icon={icon} separator={separator} collapsible={collapsible} />
)}
<div className='vz-dashboard-section-contents'>
{children}

@ -35,6 +35,7 @@ export const NumberBadge = AsyncComponent.fetchFromProps('NumberBadge');
export const TextBadge = AsyncComponent.fetchFromProps('TextBadge');
// "icon", "color", "shape", "disableColor", "className"
export const IconBadge = AsyncComponent.fetchFromProps('IconBadge');
export const Checkbox = AsyncComponent.fromDisplayName('Checkbox');
/**
* @deprecated
*/
@ -155,6 +156,12 @@ getModule(m => m.default?.displayName === 'Tooltip', true, true).then(Tooltip =>
this.Tooltip.Colors = Tooltip.TooltipColors;
});
getModuleByDisplayName('Checkbox', true, true).then(Checkbox => {
this.Checkbox.Aligns = Checkbox.Aligns;
this.Checkbox.Shapes = Checkbox.Shapes;
this.Checkbox.Types = Checkbox.Types;
});
getModuleByDisplayName('HeaderBar', true, true).then(HeaderBar => {
this.HeaderBar.Divider = HeaderBar.Divider;
this.HeaderBar.Title = HeaderBar.Title;
@ -172,6 +179,12 @@ getModuleByDisplayName('TabBar', true, true).then(TabBar => {
this.TabBar.Looks = TabBar.Looks;
this.TabBar.Item = TabBar.Item;
this.TabBar.Panel = TabBar.Panel;
this.__TabBar.Separator = TabBar.Separator;
this.__TabBar.Header = TabBar.Header;
this.__TabBar.Types = TabBar.Types;
this.__TabBar.Looks = TabBar.Looks;
this.__TabBar.Item = TabBar.Item;
});
getModuleByDisplayName('SearchBar', true, true).then(SearchBar => {

@ -39,14 +39,6 @@ export const Directories = Object.freeze({
get MODULES () { return join(__dirname, '..'); }
});
export const Vizality = Object.freeze({
get BUILTINS () {
const builtins = [];
readdirSync(Directories.BUILTINS).forEach(file => builtins.push(file));
return builtins;
}
});
export const Guild = Object.freeze({
INVITE: 'Fvmsfv2',
ID: '689933814864150552'

@ -105,7 +105,6 @@ export default class GenericRequest {
/* */ const opts = Object.assign(this.opts, resolve);
/* */ if (!opts.uri) return;
this._log('Performing request to', opts.uri);
const { request } = opts.uri.startsWith('https')
? https
: http;

Loading…
Cancel
Save