Skip to content

Commit

Permalink
Merge pull request #49 from snowsunny/bugfix
Browse files Browse the repository at this point in the history
Bugfix
  • Loading branch information
snowsunny authored Oct 5, 2020
2 parents e90058e + e0216fd commit b53b338
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion novels-reader-crx/background.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions novels-reader-crx/content.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions novels-reader-crx/options.js

Large diffs are not rendered by default.

16 changes: 11 additions & 5 deletions src/js/DictionariesManager.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import _assign from 'lodash/assign'
import _merge from 'lodash/merge'
import _find from 'lodash/find'
import localForage from 'localforage'

Expand All @@ -14,11 +15,16 @@ export default class DictionariesManager {
async saveDictionary(newDictionary, forceFlag) {
let storageDictionary = this.getDictionary({id: newDictionary.id, domain: newDictionary.domain})
if(storageDictionary) {
if(!forceFlag && storageDictionary.raw && newDictionary.raw) {
let newRubies = this.getNewRubiesOnly(newDictionary, storageDictionary)
newDictionary.raw = newRubies.length
? storageDictionary.raw + `\n${this.getDictionaryText(newRubies)}`
: storageDictionary.raw
if(!forceFlag) {
if(newDictionary.raw) {
let newline = storageDictionary.raw ? '\n' : ''
let newRubies = this.getNewRubiesOnly(newDictionary, storageDictionary)
newDictionary.raw = newRubies.length ?
storageDictionary.raw + newline + this.getDictionaryText(newRubies) :
storageDictionary.raw
} else {
newDictionary.raw = storageDictionary.raw
}
}
} else {
newDictionary.raw = newDictionary.raw || ''
Expand Down

0 comments on commit b53b338

Please sign in to comment.