From 016d3b7bd1ee5332fb11144792b9437d0428ebcd Mon Sep 17 00:00:00 2001 From: xmcp Date: Tue, 18 Jun 2019 18:38:19 +0800 Subject: [PATCH] fix reply bar and update repo name --- src/Config.js | 17 +++++++++-------- src/Flows.js | 2 +- src/Title.js | 2 +- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/Config.js b/src/Config.js index 5e1ea7f2..edb7e6f2 100644 --- a/src/Config.js +++ b/src/Config.js @@ -20,19 +20,20 @@ const DEFAULT_CONFIG={ }; export function load_config() { - let config_txt=localStorage['hole_config']||'{}'; - let config; + let config=Object.assign({},DEFAULT_CONFIG); + let loaded_config; try { - config=JSON.parse(config_txt); + loaded_config=JSON.parse(localStorage['hole_config']||'{}'); } catch(e) { alert('设置加载失败,将重置为默认设置!\n'+e); delete localStorage['hole_config']; - config={}; + loaded_config={}; } - Object.keys(DEFAULT_CONFIG).forEach((key)=>{ - if(config[key]===undefined) - config[key]=DEFAULT_CONFIG[key]; + // unrecognized configs are removed + Object.keys(loaded_config).forEach((key)=>{ + if(config[key]!==undefined) + config[key]=loaded_config[key]; }); console.log('config loaded',config); @@ -208,7 +209,7 @@ export class ConfigUI extends PureComponent {

新功能建议或问题反馈请在  - GitHub + GitHub  提出。

diff --git a/src/Flows.js b/src/Flows.js index b6a361f1..18ed4938 100644 --- a/src/Flows.js +++ b/src/Flows.js @@ -283,7 +283,7 @@ class FlowSidebar extends PureComponent { show_reply_bar(name,event) { if(this.reply_ref.current && !event.target.closest('a')) { let text=this.reply_ref.current.get(); - if(/^\s*(Re (洞主|\b[A-Z][a-z]+){0,2}:)?\s*$/.test(text)) {// text is nearly empty so we can replace it + if(/^\s*(?:Re (?:|洞主|(?:[A-Z][a-z]+ )?(?:[A-Z][a-z]+)):)?\s*$/.test(text)) {// text is nearly empty so we can replace it let should_text='Re '+name+': '; if(should_text===this.reply_ref.current.get()) this.reply_ref.current.set(''); diff --git a/src/Title.js b/src/Title.js index 37231678..ea596839 100644 --- a/src/Title.js +++ b/src/Title.js @@ -125,7 +125,7 @@ class ControlBar extends PureComponent {  /  树洞规范  /  - 意见反馈 + 意见反馈 {HELP_TEXT}