add a `Clear Plugin Scan Cache` button.

This commit is contained in:
Jean Ouina 2020-10-26 13:15:03 +01:00
parent fee98d4dd3
commit 172a909aa8
6 changed files with 73 additions and 6 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -89,6 +89,14 @@ export default new class ContentManager {
dataStore.setSettingGroup("PluginCertifierHashes", encryptSettingsCache(JSON.stringify(addonCache)))
}
resetAddonCache(){
Object.keys(addonCache).forEach(key => {
delete addonCache[key]
})
console.log(addonCache)
this.saveAddonCache()
}
watchContent(contentType) {
if (this.watchers[contentType]) return;
const isPlugin = contentType === "plugin";

View File

@ -450,4 +450,12 @@ export function encryptSettingsCache(data){
let encrypted = cipher.update(Buffer.from(data, "utf8"));
encrypted = Buffer.concat([encrypted, cipher.final()]);
return encrypted.toString("base64")
}
export function clearCaches(){
Object.keys(cache).forEach(key => {
delete cache[key]
})
Object.keys(cache2).forEach(key => {
delete cache[key]
})
}

View File

@ -33,6 +33,7 @@ import core from "./core";
import popoutWindow from "./popoutWindow";
import TextInputSetting from "../ui/TextInputSetting";
import { useForceUpdate } from "./hooks";
import { clearCaches } from "./pluginCertifier";
class BDSidebarHeader extends React.PureComponent {
render(){
@ -321,6 +322,7 @@ export default new class V2_SettingsPanel {
}
lightcordComponent(sidebar, forceUpdate) {
// this code is shit, I'm gonna rewritte everything in the next version
let appSettings = window.Lightcord.Api.settings
return [
this.lightcordSettings.map((section, i) => {
@ -461,7 +463,22 @@ export default new class V2_SettingsPanel {
},
wrapper: true,
disabled: isClearingCache
}, "Clear cache")
}, "Clear cache"),
React.createElement(Lightcord.Api.Components.inputs.Button, {
color: "yellow",
look: "ghost",
size: "medium",
hoverColor: "red",
onClick: () => {
clearCaches()
ContentManager.resetAddonCache()
Utils.showToast("Cache is cleared !", {
type: "success"
})
},
wrapper: true,
disabled: false
}, "Clear Plugin Scan Cache")
]
}