Add some error handling to windows api and more api cleanup

pull/11/head
dperolio 3 years ago
parent 8c87f411e6
commit 744d5a217d
No known key found for this signature in database
GPG Key ID: 3E9BBAA710D3DDCE

@ -282,6 +282,7 @@
"Voice": "Voice"
},
"tagNamePreference": {
"fires": "emits",
"component": "component",
"augments": "extends",
"warn": "warn",

@ -81,7 +81,6 @@
"long": "^4.0.0",
"mime-types": "^2.1.27",
"module-alias": "^2.2.2",
"pirates": "^4.0.1",
"pluralize": "^8.0.0",
"react-markdown": "^4.3.1",
"sass": "^1.26.10",

@ -16,12 +16,13 @@ import { API } from '@vizality/entities';
* @property {Object.<String, function(String): Boolean>} scopes RPC Scopes
* @property {Object.<String, DiscordRpcEvent>} scopes RPC Scopes
*/
export default class RpcAPI extends API {
export default class RPC extends API {
constructor () {
super();
this.scopes = {};
this.events = {};
this._module = 'API';
this._submodule = 'RPC';
}
/**

@ -102,20 +102,29 @@ export default class Windows extends API {
* @fires Windows#popupClosed
*/
closeWindow (windowId) {
if (!this.windows[windowId]) {
return this.error(`Window with ID "${windowId}" not found.`);
}
try {
if (!this.windows[windowId]) {
throw new Error(`Window with ID "${windowId}" not found.`);
}
const popoutModule = getModule('setAlwaysOnTop', 'open');
popoutModule.close(`DISCORD_${windowId}`);
const popoutModule = getModule('setAlwaysOnTop', 'open');
popoutModule.close(`DISCORD_${windowId}`);
delete this.windows[windowId];
delete this.windows[windowId];
} catch (err) {
return error(this._module, `${this._submodule}:closeWindow`, null, err);
}
}
setAlwaysOnTop (windowId, boolean = true) {
/**
* Sets a popup window to always be on top of other windows.
* @param {string} windowId Popup window ID
* @param {boolean} alwaysOnTop Whether the window should always be on top or not
*/
setAlwaysOnTop (windowId, alwaysOnTop = true) {
try {
const popoutModule = getModule('setAlwaysOnTop', 'open');
popoutModule.setAlwaysOnTop(`DISCORD_${windowId}`, boolean);
popoutModule.setAlwaysOnTop(`DISCORD_${windowId}`, alwaysOnTop);
} catch (err) {
return error(this._module, `${this._submodule}:setAlwaysOnTop`, null, err);
}

@ -3,10 +3,9 @@ import React, { memo, useState, useReducer, useEffect } from 'react';
import { existsSync, lstatSync, readdirSync } from 'fs';
import { join, extname } from 'path';
import { open as openModal, close as closeModal } from '@vizality/modal';
import { toPlural, toTitleCase } from '@vizality/util/string';
import { Confirm, Spinner, Text } from '@vizality/components';
import { joinClassNames } from '@vizality/util/dom';
import { Spinner } from '@vizality/components';
import { getModule } from '@vizality/webpack';
import { Messages } from '@vizality/i18n';

@ -14,6 +14,10 @@
max-width: 500px;
margin: 16px;
}
&-description {
flex: auto;
-webkit-line-clamp: 1;
}
&-content-wrapper {
padding: 7px;
}
@ -21,7 +25,7 @@
&:not([vz-previews]) {
.vz-addon-card {
&-icon {
@include size(192px);
@include size(170px);
margin-right: 10px;
}
}

Loading…
Cancel
Save