try to fix crashes and some stuffs

pull/93/head
dperolio 2 years ago
parent ff0e59d1bc
commit 8ecae18adb
No known key found for this signature in database
GPG Key ID: 4191689562D51409

@ -1,32 +1,14 @@
// const { Table } = require('@vizality/components');
import React, { memo, useState, useEffect, useRef } from 'react';
import React, { memo, useState, useEffect } from 'react';
import { UserProfile, UserPopout, Icon, SearchBar, KeyboardShortcut, KeybindRecorder, Avatar, Text, HeaderBarContainer, CarouselWithPreview, ApplicationCommandDiscoverySectionList, ApplicationStoreListingCarousel, FormNotice, Notice, NumberBadge, TextBadge, IconBadge, AsyncComponent, ProgressBar } from '@vizality/components';
import { UserProfile, UserPopout, Icon, SearchBar, KeyboardShortcut, KeybindRecorder, Text, HeaderBarContainer, CarouselWithPreview, ApplicationStoreListingCarousel, FormNotice, Notice, NumberBadge, TextBadge, IconBadge, ProgressBar } from '@vizality/components';
import { getModuleByDisplayName, getModule } from '@vizality/webpack';
const TransitionGroup = getModuleByDisplayName('TransitionGroup');
const SlideIn = getModuleByDisplayName('SlideIn');
const { getCurrentUser } = getModule('getCurrentUser');
// eslint-disable-next-line no-empty-function
const { PremiumPaymentGuildAnimation } = getModule('PremiumPaymentGuildAnimation');
const KeybindEntry = (() => {
let keybindentry;
try {
const UserSettingsKeybinds = getModuleByDisplayName('FluxContainer(UserSettingsKeybinds)')?.prototype?.render?.call({ memoizedGetStateFromStores: () => ({}) });
if (!UserSettingsKeybinds) throw 'Failed to get UserSettingsKeybinds component!';
const [ keybind ] = UserSettingsKeybinds.type?.prototype?.renderKeybinds?.call({ keybindActionTypes: {}, keybindDescriptions: {} }, [ {} ]);
if (!keybind) throw 'Failed to render fake Keybind!';
keybindentry = keybind.props?.children?.type;
if (!keybindentry) throw 'Failed to get KeybindEntry component!';
} catch (err) {
console.error(err);
keybindentry = () => null;
}
return keybindentry;
})();
// const { PremiumPaymentGuildAnimation } = getModule('PremiumPaymentGuildAnimation');
// const { usePaymentModalAnimationScene } = getModule('usePaymentModalAnimationScene');
export default memo(() => {
const [ completed, setCompleted ] = useState(0);
@ -37,7 +19,7 @@ export default memo(() => {
return (
<>
{/* e.WAITING = "WAITING",
{/* e.WAITING = "WAITING",
e.PURCHASING = "PURCHASING",
e.FAIL = "FAIL",
e.COMPLETED = "COMPLETED" */}
@ -68,11 +50,6 @@ export default memo(() => {
<Notice color={Notice.Colors.DANGER} />
<UserPopout user={getCurrentUser()} />
<UserProfile user={getCurrentUser()} />
{/* <Sticker
className='pie'
src='https://i.giphy.com/media/wTgYlmxctT2O4/giphy.webp'
/>
<Emote name='Bob' src="https://cdn.discordapp.com/avatars/97549189629636608/42091c785e85fc5c20b9f1733d6b802a.png" /> */}
<HeaderBarContainer>
<Text>I like pie</Text>
</HeaderBarContainer>
@ -153,24 +130,13 @@ export default memo(() => {
]}
renderItem={handleRender}
/> */}
{/* <Avatar
<Avatar
isTyping={true}
isMobile={true}
src='https://cdn.discordapp.com/avatars/597905003717459968/74809b431684d381a5ed0637f8adbf91.png'
status='online'
statusTooltip={true}
size={Avatar.Sizes.SIZE_32}
/> */}
<KeybindEntry
keybind={{ managed: false, id: '1', action: 'TOGGLE_MUTE', shortcut: [] }}
keybindActionTypes={[
{ label: 'Unassigned', value: 'UNASSIGNED' },
{ label: 'Push to Talk (Normal)', value: 'TOGGLE_MUTE' }
]}
keybindDescriptions={{
UNASSIGNED: 'Navigate backward in page history',
TOGGLE_MUTE: 'asdasd asda dasda ds'
}}
/>
<video autoPlay loop autoPictureInPicture controls={false}>
<source src="https://www.kelp.agency/wp-content/uploads/2020/06/orbit_1_1.webm" type="video/webm" />

@ -70,8 +70,6 @@ export default class Settings extends Builtin {
vizality.api.actions.registerAction('CONFIRM_RESTART', () => this.confirmRestart());
this.patchSettingsComponent();
this.patchExperiments();
this.patchSettingsContextMenu();
this.patchSettingsContextMenuAddonItem();
this.patchSettingsContextMenuAddonCheckboxItem();
@ -81,7 +79,6 @@ export default class Settings extends Builtin {
categories.forEach(category => vizality.api.routes.unregisterRoute(`settings/${category}`));
vizality.api.routes.unregisterRoute('settings');
vizality.api.actions.unregisterAction('CONFIRM_RESTART');
unpatch('vz-settings-items');
unpatch('vz-settings-context-menu');
unpatch('vz-settings-context-menu-addon-items');
unpatch('vz-settings-context-menu-addon-checkbox-items');
@ -106,47 +103,6 @@ export default class Settings extends Builtin {
</Confirm>);
}
patchExperiments () {
try {
const experimentsModule = getModule(r => r.isDeveloper !== void 0);
Object.defineProperty(experimentsModule, 'isDeveloper', {
get: () => vizality.settings.get('discordExperiments', false)
});
// Ensure components do get the update
experimentsModule._changeCallbacks.forEach(callback => callback());
} catch (err) {
// :eyes:
}
}
patchSettingsComponent () {
const SettingsView = getModuleByDisplayName('SettingsView');
patch('vz-settings-items', SettingsView.prototype, 'getPredicateSections', (_, sections) => {
const latestCommitHash = vizality.git.revision.substring(0, 7);
const debugInfo = sections[sections.findIndex(c => c.section === 'CUSTOM') + 1];
if (debugInfo) {
debugInfo.element = ((_element) => function () {
const res = _element();
if (res.props.children && res.props.children.length === 3) {
res.props.children.push(
Object.assign({}, res.props.children[0], {
props: Object.assign({}, res.props.children[0].props, {
children: [ 'Vizality', ' ',
<span className={res.props.children[0].props.children[4].props.className}>
{`${vizality.git.branch} (${latestCommitHash})`}
</span> ]
})
})
);
}
return res;
})(debugInfo.element);
}
return sections;
});
}
patchSettingsContextMenu () {
const DiscordSettingsContextMenu = getModule(m => m.default?.displayName === 'UserSettingsCogContextMenu');
patch('vz-settings-context-menu', DiscordSettingsContextMenu, 'default', (_, res) => {

@ -9,8 +9,7 @@ import { existsSync, promises } from 'fs';
import Markdown from 'react-markdown';
import gfm from 'remark-gfm';
import { CodeBlock, Icon, DeferredRender, Spinner, LazyImageZoomable, ImageModal, Anchor, ContextMenu } from '.';
import { CheckboxItem } from './settings';
import { CodeBlock, Icon, DeferredRender, Spinner, LazyImageZoomable, ImageModal, Anchor, ContextMenu, CheckboxItem, Flex } from '.';
const { readFile } = promises;
const { openContextMenu, closeContextMenu } = contextMenu;
@ -131,7 +130,7 @@ export default memo(({ source, type, addonId }) => {
children.forEach(child => {
if (child?.props?.type === 'checkbox') {
children =
<CheckboxItem className='vz-markdown-checkbox' align={CheckboxItem.Aligns.TOP} value={Boolean(child?.props?.checked)} readOnly={child?.props?.disabled}>
<CheckboxItem className='vz-markdown-checkbox' align={Flex.Align.TOP} value={Boolean(child?.props?.checked)} readOnly={child?.props?.disabled}>
{children[children.length - 1]}
</CheckboxItem>;
}
@ -285,10 +284,10 @@ export default memo(({ source, type, addonId }) => {
<Spinner />
</div>
}>
<Markdown children={markdown} remarkPlugins={[ gfm ]} components={renderers} />
<Markdown children={markdown} remarkPlugins={[ gfm ]} />
</DeferredRender>
)
: <Markdown children={markdown} remarkPlugins={[ gfm ]} components={renderers} />
: <Markdown children={markdown} remarkPlugins={[ gfm ]} />
}
</>
);

@ -1,6 +1,6 @@
import { __TabBar, StickyElement, ImageCarouselModal, Image, Markdown } from '@vizality/components';
import { Section } from '@vizality/components/dashboard';
import React, { memo, useEffect, useState } from 'react';
import React, { memo } from 'react';
import { openModal } from '@vizality/modal';
import { joinClassNames } from '@vizality/util/dom';
import { toPlural } from '@vizality/util/string';
@ -51,17 +51,17 @@ export default memo(({ addonId, type, section }) => {
const AddonSettings = hasSettings && addon?.sections?.settings?.render;
/**
*
*
*/
if (!addon) {
addon = vizality.manager.community[toPlural(type)].get(addonId);
}
/**
*
*
*/
if (!addon) {
return;
return <></>;
}
const scrollToTop = () => {
@ -151,7 +151,7 @@ export default memo(({ addonId, type, section }) => {
)}
{section === 'reviews' && (
<Section header='Reviews' icon='Star'>
</Section>
)}
{hasChangelog && section === 'changelog' && (

@ -1,10 +1,10 @@
import { Spinner, DeferredRender, Icon, FilterInput, HelpMessage, __TabBar, StickyElement, Popout } from '@vizality/components';
import { Spinner, DeferredRender, Icon, FilterInput, HelpMessage, __TabBar, StickyElement, Popout, EmptyStateImage } from '@vizality/components';
import { useForceUpdate, usePreviousProps, useFilter, useToggle } from '@vizality/hooks';
import { toPlural, toTitleCase } from '@vizality/util/string';
import React, { memo, useState, useEffect } from 'react';
import { unstable_batchedUpdates } from 'react-dom';
import { joinClassNames } from '@vizality/util/dom';
import { getModule, getModuleByDisplayName } from '@vizality/webpack';
import { getModule } from '@vizality/webpack';
import { error } from '@vizality/util/logger';
import { Events } from '@vizality/constants';
import { useRouteMatch } from 'react-router';
@ -75,8 +75,6 @@ const SearchResultsHeader = memo(({ query, resultsCount, limit, type, tab }) =>
* @returns {React.MemoExoticComponent<function(): React.ReactElement>}
*/
const ContentBody = memo(({ community, display, filteredResults, type, limit, resultsCount, handleResultsCount }) => {
const { emptyStateImage } = getModule('emptyStateImage', 'emptyStateSubtext');
/**
* If the filtered items count doesn't equal the current results count, update the value.
*/
@ -103,7 +101,7 @@ const ContentBody = memo(({ community, display, filteredResults, type, limit, re
)
: (
<div className='vz-addons-list-empty'>
<div className={emptyStateImage} />
<EmptyStateImage />
<p>{Messages.GIFT_CONFIRMATION_HEADER_FAIL}</p>
<p>{Messages.SEARCH_NO_RESULTS}</p>
</div>

@ -19,6 +19,7 @@ export const ContextMenu = AsyncComponent.fetchFromProps('MenuGroup', 'default')
export const PremiumPaymentGuildAnimation = AsyncComponent.fetchFromProps('PremiumPaymentGuildAnimation');
export const KeybindRecorder = AsyncComponent.fromDisplayName('KeybindRecorder');
export const Helmet = AsyncComponent.fetchFromProps('HelmetProvider', 'Helmet');
export const EmptyStateImage = AsyncComponent.fetchFromProps('EmptyStateImage');
export const UserPopout = AsyncComponent.fromDisplayName('ConnectedUserPopout');
export const HelmetProvider = AsyncComponent.fetchFromProps('HelmetProvider');
export const Autocomplete = AsyncComponent.fromDisplayName('Autocomplete');
@ -55,11 +56,13 @@ export const FormText = AsyncComponent.fromDisplayName('FormText');
export const FormItem = AsyncComponent.fromDisplayName('FormItem');
export const Spinner = AsyncComponent.fromDisplayName('Spinner');
export const SlideIn = AsyncComponent.fetchFromProps('SlideIn');
// id
// onChange
// checked
// disabled
// className
/*
* id
* onChange
* checked
* disabled
* className
*/
export const Switch = AsyncComponent.fromDisplayName('Switch');
export const TabBar = AsyncComponent.fromDisplayName('TabBar');
export const Notice = AsyncComponent.fromDisplayName('Notice');
@ -158,13 +161,6 @@ 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;
this.Checkbox.DEFAULT_PROPS = Checkbox.defaultProps;
});
getModuleByDisplayName('Popout', true, true).then(Popout => {
this.Popout.Aligns = Popout.Align;
this.Popout.Positions = Popout.Positions;

@ -23,9 +23,3 @@ getModuleByDisplayName('SwitchItem', true, true).then(SwitchItem => {
this.SwitchItem.Sizes = SwitchItem.Sizes;
this.SwitchItem.Themes = SwitchItem.Themes;
});
getModuleByDisplayName('Checkbox', true, true).then(Checkbox => {
this.CheckboxItem.Aligns = Checkbox.Aligns;
this.CheckboxItem.Shapes = Checkbox.Shapes;
this.CheckboxItem.Types = Checkbox.Types;
});

@ -5,7 +5,7 @@ export const HTTP = Object.freeze({
CDN: 'https://cdn.vizality.com',
WEBSITE: 'https://vizality.com',
TRELLO: 'https://trello.com/vizality',
get API () { return `${this.WEBSITE}/api`; },
API: 'https://api.vizality.com',
get DOCS () { return `${this.WEBSITE}/docs`; },
get ASSETS () { return `${this.CDN}/assets`; }
});

@ -7,6 +7,5 @@ export { default as discord } from './discord';
export { default as modal } from './modal';
export { default as hooks } from './hooks';
export { default as i18n } from './i18n';
export { default as http } from './http';
export * as http from './http';
export { default as util } from './util';
export { default as react } from './react';

@ -60,4 +60,4 @@ export const openModal = openNewModal;
* Opens a lazy modal (for LazyModal).
* @param {React.Component|function(): React.ReactElement} Component Component to show
*/
export const openModalLazy = openLazy
export const openModalLazy = openLazy;

@ -55,7 +55,9 @@ module.exports = class PatchedBrowserWindow extends BrowserWindow {
}
const win = new BrowserWindow(opts);
const originalLoadUrl = win.loadURL.bind(win);
Object.defineProperty(win, 'loadURL', {
get: () => PatchedBrowserWindow.loadUrl.bind(win, originalLoadUrl),
configurable: true

Loading…
Cancel
Save