Merge branch '4.2.3'

This commit is contained in:
Tamius Han 2019-08-28 18:29:15 +02:00
commit 8e7c3ce2ac
2 changed files with 17 additions and 10 deletions

View File

@ -76,7 +76,9 @@ class Settings {
async init() { async init() {
const settings = await this.get(); const settings = await this.get();
const oldVersion = settings.version;
// |—> on first setup, settings is undefined & settings.version is haram
const oldVersion = (settings && settings.version) || '0.0.0';
const currentVersion = this.getExtensionVersion(); const currentVersion = this.getExtensionVersion();
if(Debug.debug) { if(Debug.debug) {

View File

@ -1,3 +1,4 @@
import Debug from '../../conf/Debug'; import Debug from '../../conf/Debug';
import EdgeDetect from './edge-detect/EdgeDetect'; import EdgeDetect from './edge-detect/EdgeDetect';
import EdgeStatus from './edge-detect/enums/EdgeStatusEnum'; import EdgeStatus from './edge-detect/enums/EdgeStatusEnum';
@ -206,15 +207,23 @@ class ArDetector {
this.conf.resizer.setLastAr({type: AspectRatio.Automatic, ratio: this.getDefaultAr()}); this.conf.resizer.setLastAr({type: AspectRatio.Automatic, ratio: this.getDefaultAr()});
} }
// launch main() if it's currently not running: // launch main() if it's currently not running:
this.main(); this.main();
// automatic detection starts halted. If halted=false when main first starts, extension won't run
// this._paused is undefined the first time we run this function, which is effectively the same thing
// as false. Still, we'll explicitly fix this here.
this._paused = false;
this._halted = false; this._halted = false;
this._paused = false; this._paused = false;
} }
unpause() { unpause() {
if(this._paused){ // resume only if we explicitly paused // pause only if we were running before. Don't pause if we aren't running
this.start(); // (we are running when _halted is neither true nor undefined)
if (this._paused && this._halted === false) {
this._paused = true;
} }
} }
@ -233,12 +242,14 @@ class ArDetector {
} }
async main() { async main() {
if (this.paused) { if (this._paused) {
// unpause if paused // unpause if paused
this._paused = false; this._paused = false;
return; // main loop still keeps executing. Return is needed to avoid a million instances of autodetection
} }
if (!this._halted) { if (!this._halted) {
// we are already running, don't run twice // we are already running, don't run twice
// this would have handled the 'paused' from before, actually.
return; return;
} }
@ -731,12 +742,6 @@ class ArDetector {
this.guardline.reset(); this.guardline.reset();
this.conf.resizer.setAr({type: AspectRatio.Automatic, ratio: this.getDefaultAr()}); this.conf.resizer.setAr({type: AspectRatio.Automatic, ratio: this.getDefaultAr()});
} }
// }
// else{
// console.log("detected text on edges, dooing nothing")
// }
} }
resetBlackLevel(){ resetBlackLevel(){