Skip to content

Commit

Permalink
Prevent image list dupes
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherwk210 committed Apr 15, 2018
1 parent 17fb6c5 commit 82173f8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/assets/scripts/image-item.class.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ipcRenderer } from 'electron';
import path from 'path';

const Status = {
export const Status = {
DONE: 'done',
LOADING: 'loading',
ERROR: 'error'
Expand Down
15 changes: 14 additions & 1 deletion src/assets/scripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ if (env === 'production') {
}

// Local imports
import { ImageItem } from './image-item.class';
import { ImageItem, Status } from './image-item.class';
import SettingsComponent from '../../components/settings/settings.component';

// Prevent zooming on mac
Expand Down Expand Up @@ -54,6 +54,19 @@ let app = new Vue({
* @param {number} size File size
*/
addImage: function(path, size) {
let skip = false;
this.imageList.some(img => {
if (img.path === path) {
if (img.status !== Status.LOADING) {
img.status = Status.LOADING;
img.beginUpload();
}

skip = true;
return true;
}
});

let img = new ImageItem(path, size);
img.beginUpload();
this.imageList.push(img);
Expand Down

0 comments on commit 82173f8

Please sign in to comment.