Skip to content

Commit

Permalink
fix: 当添加重复路径问题
Browse files Browse the repository at this point in the history
不会重复添加相同路径
  • Loading branch information
Qquanwei committed May 31, 2022
1 parent efa1f2b commit 7288eea
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "electron-webtoon",
"productName": "electron-webtoon",
"version": "2.3.5",
"version": "2.3.6",
"description": "Electron application boilerplate based on React, React Router, Webpack, React Hot Loader for rapid application development",
"main": "./main.prod.js",
"author": {
Expand Down
38 changes: 28 additions & 10 deletions src/server/comicsservice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,21 +172,39 @@ export default class ComicService {
return R.find(R.propEq('id', id), library);
}

async addComicToLibrary(comicpath: string) {

isExistsAndTouch(comicPath: string) {
const library = this.store.get('library');
const newLibrary = (library || []).concat(
await this.buildNewComic(comicpath)
);
this.store.set('library', newLibrary);
const index = R.findIndex(R.propEq('path', comicPath), library);

if (index !== -1) {
const newLibrary = [...library];
newLibrary.splice(index, 1);
this.store.set('library', [...newLibrary, library[index]]);
return true;
}
return false;
}

async addComicToLibrary(comicpath: string) {
if (!this.isExistsAndTouch(comicpath)) {
const library = this.store.get('library');
const newLibrary = (library || []).concat(
await this.buildNewComic(comicpath)
);
this.store.set('library', newLibrary);
}
}

// add compress file meta info to config
async addComicToLibrary2(comicpath: string, compressFilePath: string) {
const library = this.store.get('library');
const newComic = await this.buildNewComic(comicpath);
newComic.compressFilePath = compressFilePath;
const newLibrary = (library || []).concat(newComic);
this.store.set('library', newLibrary);
if (!this.isExistsAndTouch(comicpath)) {
const library = this.store.get('library');
const newComic = await this.buildNewComic(comicpath);
newComic.compressFilePath = compressFilePath;
const newLibrary = (library || []).concat(newComic);
this.store.set('library', newLibrary);
}
}

// 打开文件选择对话框
Expand Down

0 comments on commit 7288eea

Please sign in to comment.