Remove Vizality guild button injection (temporary) and change VizalityNative to vizality.native

pull/2/head
dperolio 4 years ago
parent 33a3688646
commit ca136afc69

@ -3,7 +3,6 @@
"vizality": true,
"webpackJsonp": true,
"DiscordNative": false,
"VizalityNative": false,
"GLOBAL_ENV": true
},
"parserOptions": {

@ -13,7 +13,7 @@ const Routes = require('./routes/Routes');
module.exports = class Dashboard extends Builtin {
onStart () {
this.injectStyles('styles/main.scss');
this.injectGuildsButton();
// this.injectGuildsButton();
this.injectChannels();
vizality.api.router.registerRoute({
@ -71,40 +71,74 @@ module.exports = class Dashboard extends Builtin {
forceUpdateElement(`.${containerDefault}`, true);
}
async injectGuildsButton () {
return void 0;
const { listItemTooltip } = getModule('listItemTooltip');
const guildClasses = getModule('tutorialContainer');
const guildElement = (await waitForElement(`.${guildClasses.tutorialContainer.split(' ')[0]}`)).parentElement;
const instance = getOwnerInstance(guildElement);
patch('vz-dashboard-guilds-button', instance, 'render', (_, res) => {
console.log(res.props);
const VizalityGuildButton = React.createElement('div', {
class: 'listItem-2P_4kh vizality-dashboard-guild-button',
onClick: async () => vizality.api.router.navigate('/dashboard')
}, React.createElement(Tooltip, {
text: 'Vizality Dashboard',
position: 'right',
tooltipClassName: listItemTooltip
}, React.createElement('div', {
className: 'pill-31IEus wrapper-sa6paO'
}, React.createElement('span', {
className: 'item-2hkk8m'
})), React.createElement('div', {
className: 'vizality-dashboard-guild-icon-wrapper'
}, React.createElement(Icon, {
class: 'vizality-dashboard-guild-icon',
name: 'Vizality',
width: '30px',
height: '30px'
}))));
res.props.children[1].props.children.splice(1, 0, VizalityGuildButton);
// async injectGuildsButton () {
// return void 0;
// const { listItemTooltip } = getModule('listItemTooltip');
// const guildClasses = getModule('tutorialContainer');
// const guildElement = (await waitForElement(`.${guildClasses.tutorialContainer.split(' ')[0]}`)).parentElement;
// const instance = getOwnerInstance(guildElement);
return res;
});
// patch('vz-dashboard-guilds-button', instance, 'render', (_, res) => {
// console.log(res.props);
// const VizalityGuildButton = React.createElement('div', {
// class: 'listItem-2P_4kh vizality-dashboard-guild-button',
// onClick: async () => vizality.api.router.navigate('/dashboard')
// }, React.createElement(Tooltip, {
// text: 'Vizality Dashboard',
// position: 'right',
// tooltipClassName: listItemTooltip
// }, React.createElement('div', {
// className: 'pill-31IEus wrapper-sa6paO'
// }, React.createElement('span', {
// className: 'item-2hkk8m'
// })), React.createElement('div', {
// className: 'vizality-dashboard-guild-icon-wrapper'
// }, React.createElement(Icon, {
// class: 'vizality-dashboard-guild-icon',
// name: 'Vizality',
// width: '30px',
// height: '30px'
// }))));
setImmediate(() => forceUpdateElement(`.${guildElement.className.split(' ')[0]}`, true));
}
// res.props.children[1].props.children.splice(1, 0, VizalityGuildButton);
// return res;
// });
// async injectGuildsButton () {
// const { listItemTooltip } = getModule('listItemTooltip');
// const guildClasses = getModule('tutorialContainer');
// const guildElement = (await waitForElement(`.${guildClasses.tutorialContainer.split(' ')[0]}`)).parentElement;
// const instance = getOwnerInstance(guildElement);
// patch('vz-dashboard-guilds-button', instance, 'render', function (_, res) {
// console.log(this);
// console.log(res);
// const VizalityGuildButton = React.createElement('div', {
// class: 'listItem-2P_4kh vizality-dashboard-guild-button',
// onClick: async () => vizality.api.router.navigate('/dashboard')
// }, React.createElement(Tooltip, {
// text: 'Vizality Dashboard',
// position: 'right',
// tooltipClassName: listItemTooltip
// }, React.createElement('div', {
// className: 'pill-31IEus wrapper-sa6paO'
// }, React.createElement('span', {
// className: 'item-2hkk8m'
// })), React.createElement('div', {
// className: 'vizality-dashboard-guild-icon-wrapper'
// }, React.createElement(Icon, {
// class: 'vizality-dashboard-guild-icon',
// name: 'Vizality',
// width: '30px',
// height: '30px'
// }))));
// res.props.children[1].props.children.splice(1, 0, VizalityGuildButton);
// return res;
// });
// setImmediate(() => forceUpdateElement(`.${guildElement.className.split(' ')[0]}`, true));
// }
};

@ -110,7 +110,7 @@ module.exports = class SplashScreen extends React.PureComponent {
}
};
// this._window = VizalityNative.openBrowserWindow(windowSettings);
// this._window = vizality.native.openBrowserWindow(windowSettings);
this._window = new BrowserWindow(windowSettings);
this._window.loadURL(splashIndex);
this._window.webContents.openDevTools({ mode: 'detach' });

@ -12,7 +12,7 @@ module.exports = React.memo(({ getSetting, toggleSetting, updateSetting }) => {
const clearDiscordCache = () => {
setDiscordCacheCleared(true);
VizalityNative.clearCache().then(() => {
vizality.native.clearCache().then(() => {
setTimeout(() => {
setDiscordCacheCleared(false);
}, 2500);

@ -1,5 +1,5 @@
const { getModule, getModuleByPrototypes, initialize } = require('@webpack');
const { sleep, logger: { log, warn, error } } = require('@util');
const { getModule, initialize } = require('@webpack');
const { HTTP, Directories } = require('@constants');
const { jsx: JsxCompiler } = require('@compilers');
const { Updatable } = require('@entities');
@ -67,6 +67,14 @@ module.exports = class Vizality extends Updatable {
constructor () {
super(Directories.ROOT, '', 'vizality');
/*
* Copy over the VizalityNative to vizality.native and then delete
* VizalityNative, so that we are staying consistent and only have
* one top level global variable.
*/
this.native = global.VizalityNative;
delete global.VizalityNative;
this.api = {};
this.modules = {};
this.manager = {};
@ -157,7 +165,7 @@ module.exports = class Vizality extends Updatable {
* });
*/
// Builtins
// Builtins
await this.manager.builtins.load();
// Themes

@ -258,7 +258,7 @@ class StyleManager {
text: 'Open Developer Tools',
color: 'green',
look: 'ghost',
onClick: () => VizalityNative.openDevTools()
onClick: () => vizality.native.openDevTools()
}
]
});
@ -273,7 +273,7 @@ class StyleManager {
text: 'Open Developer Tools',
color: 'green',
look: 'ghost',
onClick: () => VizalityNative.openDevTools()
onClick: () => vizality.native.openDevTools()
}
]
});

@ -84,7 +84,6 @@ module.exports = React.memo(function VizalityCodeBlock ({
*/
/** @private **/
function renderCode (language, content) {
console.log(content);
return (
<>
{language && !contentIsRaw && highlight(language, content, true)

@ -6,16 +6,11 @@
* @version 0.0.1
*/
const { error } = require('../logger');
/**
* @todo Add: isType, assertType, isHex, isHsl, isInt, isRgb, assertHex, assertHsl, assertInt, assertRgb
* @todo Make these work with 8-digit hex numbers, rgba, and hsla.
*/
const _module = 'Module';
const _submodule = 'Util:Color';
const color = module.exports = {
_hex2hsl (color) {
// Convert hex to RGB first
@ -513,9 +508,6 @@ const color = module.exports = {
if (ex.hex.test(color)) { return 'hex'; }
if (ex.hsl.test(color)) { return 'hsl'; }
if (Number.isInteger(parseInt(color))) { return 'int'; }
// @todo Proper error message
return error(_module, `${_submodule}:getType`, null, 'Color type is not valid. Valid types are "hex", "int", "rgb", and "hsl".');
},
toHex (input) {

@ -90,6 +90,6 @@ try {
// Overlay devtools
vizality.once('initialized', () => {
if (window.__OVERLAY__ && vizality.api.settings.store.getSetting('settings', 'openOverlayDevTools', false)) {
VizalityNative.openDevTools({}, true);
vizality.native.openDevTools({}, true);
}
});

Loading…
Cancel
Save