From 6372743f9f9fe608b4cd3a9e21ae7b469469904d Mon Sep 17 00:00:00 2001 From: Alexei Stukov Date: Sun, 30 Apr 2017 14:21:19 +0300 Subject: [PATCH] Fixed theme and plugin state not saving --- js/main.min.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/js/main.min.js b/js/main.min.js index e959327f..0858ab84 100644 --- a/js/main.min.js +++ b/js/main.min.js @@ -497,12 +497,14 @@ setInitialState(){this.state={'checked':pluginCookie[this.props.plugin.getName() componentDidUpdate(){if(this.state.settings){if(typeof this.settingsPanel==="object"){this.refs.settingspanel.appendChild(this.settingsPanel)}}} render(){let self=this;let{plugin}=this.props;let name=plugin.getName();let author=plugin.getAuthor();let description=plugin.getDescription();let version=plugin.getVersion();let{settingsPanel}=this;if(this.state.settings){return BDV2.react.createElement("li",{style:{maxHeight:"500px",overflow:"auto"}},BDV2.react.createElement("div",{style:{float:"right",cursor:"pointer"},onClick:()=>{this.refs.settingspanel.innerHTML="";self.setState({'settings':!1})}},BDV2.react.createElement(V2Components.XSvg,null)),typeof settingsPanel==='object'&&BDV2.react.createElement("div",{ref:"settingspanel"}),typeof settingsPanel!=='object'&&BDV2.react.createElement("div",{ref:"settingspanel",dangerouslySetInnerHTML:{__html:plugin.getSettingsPanel()}}))} return BDV2.react.createElement("li",null,BDV2.react.createElement("div",{className:"bda-left"},BDV2.react.createElement("span",{className:"bda-name"},name," v",version," by ",author),BDV2.react.createElement("div",{className:"scroller-wrap fade"},BDV2.react.createElement("div",{className:"scroller bda-description"},description))),BDV2.react.createElement("div",{className:"bda-right"},BDV2.react.createElement("label",{className:"ui-switch-wrapper ui-flex-child",style:{flex:'0 0 auto'}},BDV2.react.createElement("input",{checked:this.state.checked,onChange:this.onChange,className:"ui-switch-checkbox",type:"checkbox"}),BDV2.react.createElement("div",{className:"ui-switch"})),this.settingsPanel&&BDV2.react.createElement("button",{onClick:this.showSettings},"Settings")))} -onChange(){let self=this;self.setState({'checked':!self.state.checked});pluginCookie[self.props.plugin.getName()]=!self.state.checked;if(!self.state.checked){self.props.plugin.start()}else{self.props.plugin.stop()}} +onChange(){let self=this;self.setState({'checked':!self.state.checked});pluginCookie[self.props.plugin.getName()]=!self.state.checked;if(!self.state.checked){self.props.plugin.start()}else{self.props.plugin.stop()} +$.cookie("bd-plugins",JSON.stringify(pluginCookie),{expires:365,path:'/'})} showSettings(){if(!this.settingsPanel)return;this.setState({'settings':!0})}} class V2C_ThemeCard extends BDV2.reactComponent{constructor(props){super(props);this.setInitialState();this.onChange=this.onChange.bind(this)} setInitialState(){this.state={'checked':themeCookie[this.props.theme.name]}} render(){let{theme}=this.props;let name=theme.name.replace('_',' ');let description=theme.description;let version=theme.version;let author=theme.author;return BDV2.react.createElement("li",null,BDV2.react.createElement("div",{className:"bda-left"},BDV2.react.createElement("span",{className:"bda-name"},name," v",version," by ",author),BDV2.react.createElement("div",{className:"scroller-wrap fade"},BDV2.react.createElement("div",{className:"scroller bda-description"},description))),BDV2.react.createElement("div",{className:"bda-right"},BDV2.react.createElement("label",{className:"ui-switch-wrapper ui-flex-child",style:{flex:'0 0 auto'}},BDV2.react.createElement("input",{checked:this.state.checked,onChange:this.onChange,className:"ui-switch-checkbox",type:"checkbox"}),BDV2.react.createElement("div",{className:"ui-switch"}))))} -onChange(){let self=this;self.setState({'checked':!self.state.checked});themeCookie[self.props.theme.name]=!self.state.checked;if(!self.state.checked){$("head").append(``)}else{$(`#${self.props.theme.name}`).remove()}}} +onChange(){let self=this;self.setState({'checked':!self.state.checked});themeCookie[self.props.theme.name]=!self.state.checked;if(!self.state.checked){$("head").append(``)}else{$(`#${self.props.theme.name}`).remove()} +$.cookie("bd-themes",JSON.stringify(themeCookie),{expires:365,path:'/'})}} class V2Cs_TabBar{static get Item(){return V2C_TabBarItem} static get Header(){return V2C_TabBarHeader} static get Separator(){return V2C_TabBarSeparator}}