Merge pull request #91 from bakzkndd/stable

Fix that Addon installer!
pull/92/head
dperolio 2 years ago committed by GitHub
commit ff0e59d1bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -18,7 +18,7 @@ export default async builtin => {
const instance = getOwnerInstance(await waitForElement(`.${iconWrapper}`));
patch('vz-attributes-channel-header-buttons', instance?.__proto__, 'render', (_, res) => {
try {
if (!res.props?.children?.props?.className.includes(iconWrapper, clickable)) {
if (!res.props?.children?.props?.className?.includes(iconWrapper, clickable)) {
return res;
}
/**

@ -21,7 +21,7 @@ const KeybindEntry = (() => {
keybindentry = keybind.props?.children?.type;
if (!keybindentry) throw 'Failed to get KeybindEntry component!';
} catch (err) {
console.err(err);
console.error(err);
keybindentry = () => null;
}

@ -7,7 +7,7 @@ import fs, { stat, renameSync, readFileSync, existsSync, lstatSync, readdirSync
import { AddonInfoMessage, AddonUninstallModal } from '@vizality/components/addon';
import { removeDirRecursive } from '@vizality/util/file';
import { log, warn, error } from '@vizality/util/logger';
import { open as openModal } from '@vizality/modal';
import { openModalLazy as openModal } from '@vizality/modal';
import { isArray } from '@vizality/util/array';
import { Avatars, Events as _Events } from '@vizality/constants';
import http from 'isomorphic-git/http/node';
@ -565,6 +565,13 @@ export default class AddonManager extends Events {
git = `https://github.com/vizality-community/${addonId}`;
}
/**
* The addonId supplied might be a GitHub repository URL
*/
if (!git) {
git = addonId
}
/**
* The URL must end in git to get processed by isomorphic-git below.
*/
@ -635,7 +642,7 @@ export default class AddonManager extends Events {
vizality.api.notifications.sendToast({
id: 'addon-installed',
header: Messages.VIZALITY_ADDON_SUCCESSFULLY_INSTALLED.format({ type: toTitleCase(this.type) }),
content: <AddonInfoMessage addon={this.get(addonId)} message={Messages.VIZALITY_ADDON_SUCCESSFULLY_INSTALLED_DESC.format({ type: toTitleCase(this.type) })} />,
content: <AddonInfoMessage addon={this.get(addonId) || { manifest: { name: addonId }}} message={Messages.VIZALITY_ADDON_SUCCESSFULLY_INSTALLED_DESC.format({ type: toTitleCase(this.type) })} />,
icon: toTitleCase(this.type),
buttons: [
{
@ -920,7 +927,9 @@ export default class AddonManager extends Events {
if (!addon) {
return;
}
openModal(() => <AddonUninstallModal addon={addon} type={this.type} />);
if (!openModal) return this._error(`Can't find DeprecatedModal module within Discord`)
openModal(() => ModalArgs => <AddonUninstallModal {...ModalArgs} addon={addon} type={this.type} />);
} catch (err) {
return this._error(err);
}

@ -5,8 +5,8 @@ import AsyncComponent from './AsyncComponent';
export default AsyncComponent.from((async () => {
/* Thanks to Harley for this~ */
const GuildFolderSettingsModal = await getModuleByDisplayName('GuildFolderSettingsModal', true);
const ModalRoot = GuildFolderSettingsModal?.prototype?.render?.call({ props: { transitionState: 0 }, state: { name: '', color: '' } });
const GuildFolderNode = await getModuleByDisplayName('GuildFolderNode', true);
const ModalRoot = GuildFolderNode?.prototype?.render?.call({ props: { transitionState: 0 }, state: { name: '', color: '' } });
const SuspendedPicker = findInReactTree(ModalRoot, n => n.props?.defaultColor)?.type;
const LazyWebpackModule = await SuspendedPicker()?.props?.children?.type;
const mdl = await (LazyWebpackModule?._ctor || LazyWebpackModule?._payload?._result)();

@ -20,7 +20,7 @@ export default memo(({ addon, message, iconSize }) => {
<ul className='vz-addon-info-message-ul'>
<li className='vz-addon-info-message-li' vz-addon-id={addon?.addonId} key={addon?.addonId}>
<div className='vz-addon-info-message-icon'>
{addon && (
{addon?.manifest?.icon && (
<LazyImage
className='vz-addon-info-message-icon-image-wrapper'
imageClassName='vz-addon-info-message-icon-img'

@ -1,5 +1,4 @@
import { toTitleCase, toPlural } from '@vizality/util/string';
import { close as closeModal } from '@vizality/modal';
import { Messages } from '@vizality/i18n';
import { AddonInfoMessage } from '.';
import React, { memo } from 'react';
@ -12,15 +11,15 @@ import { Confirm } from '..';
* @param {object} props.addon Addon
* @param {string} props.type Addon type
*/
export default memo(({ addon, type }) => {
export default memo(({ onClose, addon, type }) => {
return (
<Confirm
header={Messages.VIZALITY_ADDON_UNINSTALL.format({ type: toTitleCase(type) })}
confirmText={Messages.VIZALITY_UNINSTALL}
cancelText={Messages.CANCEL}
onCancel={closeModal}
onCancel={onClose}
onConfirm={async () => {
closeModal();
onClose();
await vizality.manager[toPlural(type)]?._uninstall(addon.addonId);
}}
>

@ -7,7 +7,7 @@ import { getModule, modal } from '@vizality/webpack';
import { deprecate } from '@vizality/util/logger';
import React from 'react';
const { closeModal: closeNewModal, openModal: openNewModal } = getModule('openModal', 'openModalLazy');
const { closeModal: closeNewModal, openModal: openNewModal, openModalLazy: openLazy } = getModule('openModal', 'openModalLazy');
/**
* Opens a new modal.
@ -55,3 +55,9 @@ export const closeModal = closeNewModal;
* @param {React.Component|function(): React.ReactElement} Component Component to show
*/
export const openModal = openNewModal;
/**
* Opens a lazy modal (for LazyModal).
* @param {React.Component|function(): React.ReactElement} Component Component to show
*/
export const openModalLazy = openLazy
Loading…
Cancel
Save