Skip to content

Commit d434923

Browse files
committed
Moved syncDiagram to after setItem; ignore imageBase64 when saving item.
1 parent 7c03411 commit d434923

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

src/components/app.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,10 @@ BookLibService.Borrow(id) {
764764

765765
console.log('on saving, ', this.state.currentItem);
766766

767+
itemService
768+
.setItem(key || this.state.currentItem.id, this.state.currentItem)
769+
.then(onSaveComplete.bind(this));
770+
767771
try {
768772
const result = await syncDiagram(this.state.currentItem);
769773
if(result) {
@@ -772,10 +776,6 @@ BookLibService.Borrow(id) {
772776
} catch (e) {
773777
console.error(e);
774778
}
775-
776-
return itemService
777-
.setItem(key || this.state.currentItem.id, this.state.currentItem)
778-
.then(onSaveComplete.bind(this));
779779
}
780780

781781
// Save current item to storage

src/itemService.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ if (window.zenumlDesktop) {
7474
},
7575

7676
async setItem(id, item) {
77+
// Saving imageBase64 in localStorage often cause errors due to size limit.
78+
item.imageBase64 = undefined;
7779
const d = deferred();
7880
var remotePromise;
7981
// TODO: check why we need to save locally always?

src/services/syncService.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ import firebase from 'firebase/app';
22

33
async function syncDiagram(currentItem) {
44
if(location.host === 'localhost:8080') {
5-
console.log('!! Skipping sync-diagram call in local environment');
5+
console.log('Skipping sync-diagram call in local environment');
66
return;
77
}
88

99
const { id, title, js, imageBase64 } = currentItem;
1010
if (!js || !title || !imageBase64) {
11-
throw Error('Cannot sync diagram because of missing data');
11+
console.error('Cannot sync diagram because of missing data', currentItem.js, currentItem.title, currentItem.imageBase64);
12+
return;
1213
}
1314

1415
const token = await firebase.auth().currentUser.getIdToken(true);

0 commit comments

Comments
 (0)