Fix for ZeresPluginLibrary's check update button

This commit is contained in:
Jean Ouina 2020-07-05 10:39:11 +02:00
parent cd1167b2c0
commit 17552f6a38
1 changed files with 32 additions and 0 deletions

View File

@ -14,6 +14,8 @@ import pluginModule from "../modules/pluginModule";
import themeModule from "../modules/themeModule";
import WebpackModules from "../modules/webpackModules";
import BdApi from "../modules/bdApi";
import Utils from "../modules/utils";
import tooltipWrap from "./tooltipWrap";
const Tooltip = WebpackModules.findByDisplayName("Tooltip");
@ -146,6 +148,35 @@ export default class CardList extends BDV2.reactComponent {
getDescription(addon) {return this.getString(addon.plugin ? addon.plugin.getDescription() : addon.description);}
getVersion(addon) {return this.getString(addon.plugin ? addon.plugin.getVersion() : addon.version);}
renderCheckUpdates(){
if(!window.ZeresPluginLibrary)return null
if(!window.PluginUpdates)return null
if(typeof window.PluginUpdates.checkAll !== "function")return null
if(!this.isPlugins)return null
return <tooltipWrap text="Checks for updates of plugins that support this feature. Right-click for a list.">
<span style={{marginLeft: "10px"}}>
<Lightcord.Api.Components.inputs.Button color="brand" look="filled" size="min" hoverColor="default" onClick={() => {
try{
Utils.showToast("Plugin update check in progress.", {type: "info"})
window.PluginUpdates.checkAll()
.then(() => {
Utils.showToast("Plugin update check complete.", {type: "success"})
}).catch(err => {
console.error(err)
Utils.showToast("An error occured while checking update.", {type: "error"})
})
}catch(e){
console.error(e)
Utils.showToast("An error occured while checking update.", {type: "error"})
}
}} wrapper={false} disabled={false}>
Check for Updates
</Lightcord.Api.Components.inputs.Button>
</span>
</tooltipWrap>
}
render() {
const refreshIcon = <Tooltip color="black" position="top" text="Reload List">
{(props) =>
@ -159,6 +190,7 @@ export default class CardList extends BDV2.reactComponent {
return <ContentColumn title={`${this.props.type.toUpperCase()}${addonCards.length}`}>
<button key="folder-button" className="bd-button bd-pfbtn" onClick={this.openFolder.bind(this)}>Open {this.isPlugins ? "Plugin" : "Theme"} Folder</button>
{this.renderCheckUpdates()}
{!settingsCookie["fork-ps-5"] && refreshIcon}
<div className="bd-controls bd-addon-controls">
<Search onChange={this.search} placeholder={`Search ${this.props.type}...`} />