Skip to content

Commit cbb44f4

Browse files
committed
Fixed location synchronization
1 parent 0a2d839 commit cbb44f4

16 files changed

+53
-60
lines changed

src/components/Modal.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,8 @@ export default {
209209
color: #de2c00;
210210
}
211211
212-
.modal__tip {
213-
background-color: transparentize(#ffd600, 0.85);
212+
.modal__info {
213+
background-color: $info-bg;
214214
border-radius: $border-radius-base;
215215
margin: 1.2em 0;
216216
padding: 0.75em 1.25em;

src/components/SideBar.vue

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,10 @@ export default {
143143
}
144144
}
145145
146-
.side-bar__warning {
146+
.side-bar__info {
147147
padding: 10px;
148148
margin: 0 -10px;
149-
color: darken($error-color, 10);
150-
background-color: transparentize($error-color, 0.925);
149+
background-color: $info-bg;
151150
152151
p {
153152
margin: 10px;

src/components/common/variables.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ $line-height-base: 1.67;
44
$line-height-title: 1.33;
55
$font-size-monospace: 0.85em;
66
$code-bg: rgba(0, 0, 0, 0.05);
7+
$info-bg: transparentize(#ffb000, 0.85);
78
$code-border-radius: 2px;
89
$link-color: #0c93e4;
910
$error-color: #f20;

src/components/menus/ExportMenu.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<menu-entry @click.native="exportMarkdown">
44
<icon-download slot="icon"></icon-download>
55
<div>Export as Markdown</div>
6-
<span>Save file as plain text.</span>
6+
<span>Save plain text file.</span>
77
</menu-entry>
88
<menu-entry @click.native="exportHtml">
99
<icon-download slot="icon"></icon-download>

src/components/menus/PublishMenu.vue

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<template>
22
<div class="side-bar__panel side-bar__panel--menu">
3-
<div class="side-bar__warning" v-if="publishLocations.length">
3+
<div class="side-bar__info" v-if="publishLocations.length">
44
<p><b>{{currentFileName}}</b> is already published.</p>
5-
<menu-entry v-if="!offline" @click.native="requestPublish">
5+
<menu-entry @click.native="requestPublish">
66
<icon-upload slot="icon"></icon-upload>
77
<div>Publish now</div>
8-
<span>Upload current file to its publication locations.</span>
8+
<span>Update current file publications.</span>
99
</menu-entry>
1010
<menu-entry @click.native="managePublish">
1111
<icon-view-list slot="icon"></icon-view-list>
@@ -120,9 +120,6 @@ export default {
120120
MenuEntry,
121121
},
122122
computed: {
123-
...mapState([
124-
'offline',
125-
]),
126123
...mapState('queue', [
127124
'isPublishRequested',
128125
]),

src/components/menus/SyncMenu.vue

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
11
<template>
22
<div class="side-bar__panel side-bar__panel--menu">
3-
<div class="side-bar__warning" v-if="syncLocations.length">
3+
<div class="side-bar__info" v-if="syncLocations.length">
44
<p><b>{{currentFileName}}</b> is already synchronized.</p>
5-
<menu-entry v-if="!offline && isSyncPossible" @click.native="requestSync">
5+
<menu-entry v-if="isSyncPossible" @click.native="requestSync">
66
<icon-sync slot="icon"></icon-sync>
77
<div>Synchronize now</div>
8-
<span>Download, merge and upload file changes.</span>
8+
<span>Download / upload file changes.</span>
99
</menu-entry>
1010
<menu-entry @click.native="manageSync">
1111
<icon-view-list slot="icon"></icon-view-list>
1212
<div>File synchronization</div>
1313
<span>Manage current file synchronized locations.</span>
1414
</menu-entry>
1515
</div>
16-
<div v-else-if="!offline && isSyncPossible">
17-
<menu-entry @click.native="requestSync">
18-
<icon-sync slot="icon"></icon-sync>
19-
<div>Synchronize now</div>
20-
<span>Download, merge and upload file changes.</span>
21-
</menu-entry>
22-
</div>
16+
<menu-entry v-else-if="isSyncPossible" @click.native="requestSync">
17+
<icon-sync slot="icon"></icon-sync>
18+
<div>Synchronize now</div>
19+
<span>Download / upload file changes.</span>
20+
</menu-entry>
2321
<hr>
2422
<div v-for="token in googleDriveTokens" :key="token.sub">
2523
<menu-entry @click.native="openGoogleDrive(token)">
@@ -99,9 +97,6 @@ export default {
9997
MenuEntry,
10098
},
10199
computed: {
102-
...mapState([
103-
'offline',
104-
]),
105100
...mapState('queue', [
106101
'isSyncRequested',
107102
]),

src/components/modals/BloggerPagePublishModal.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<a href="javascript:void(0)" @click="configureTemplates">Configure templates</a>
2525
</div>
2626
</form-entry>
27-
<div class="modal__tip">
27+
<div class="modal__info">
2828
<b>ProTip:</b> You can provide a value for <code>title</code> in the <a href="javascript:void(0)" @click="openFileProperties">file properties</a>.
2929
</div>
3030
<div class="modal__button-bar">

src/components/modals/BloggerPublishModal.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<a href="javascript:void(0)" @click="configureTemplates">Configure templates</a>
2525
</div>
2626
</form-entry>
27-
<div class="modal__tip">
27+
<div class="modal__info">
2828
<b>ProTip:</b> You can provide values for <code>title</code>, <code>tags</code>,
2929
<code>status</code> and <code>date</code> in the <a href="javascript:void(0)" @click="openFileProperties">file properties</a>.
3030
</div>

src/components/modals/GistPublishModal.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
<a href="javascript:void(0)" @click="configureTemplates">Configure templates</a>
3232
</div>
3333
</form-entry>
34-
<div class="modal__tip">
34+
<div class="modal__info">
3535
<b>ProTip:</b> You can provide a value for <code>title</code> in the <a href="javascript:void(0)" @click="openFileProperties">file properties</a>.
3636
</div>
3737
<div class="modal__button-bar">

src/components/modals/GoogleDrivePublishModal.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
<a href="javascript:void(0)" @click="configureTemplates">Configure templates</a>
4343
</div>
4444
</form-entry>
45-
<div class="modal__tip">
45+
<div class="modal__info">
4646
<b>ProTip:</b> You can provide a value for <code>title</code> in the <a href="javascript:void(0)" @click="openFileProperties">file properties</a>.
4747
</div>
4848
<div class="modal__button-bar">

src/components/modals/WordpressPublishModal.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<a href="javascript:void(0)" @click="configureTemplates">Configure templates</a>
2626
</div>
2727
</form-entry>
28-
<div class="modal__tip">
28+
<div class="modal__info">
2929
<b>ProTip:</b> You can provide values for <code>title</code>, <code>tags</code>,
3030
<code>categories</code>, <code>excerpt</code>, <code>author</code>, <code>featuredImage</code>,
3131
<code>status</code> and <code>date</code> in the <a href="javascript:void(0)" @click="openFileProperties">file properties</a>.

src/components/modals/ZendeskPublishModal.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
<a href="javascript:void(0)" @click="configureTemplates">Configure templates</a>
3131
</div>
3232
</form-entry>
33-
<div class="modal__tip">
33+
<div class="modal__info">
3434
<b>ProTip:</b> You can provide values for <code>title</code>, <code>tags</code> and
3535
<code>status</code> in the <a href="javascript:void(0)" @click="openFileProperties">file properties</a>.
3636
</div>

src/services/networkSvc.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,5 +264,8 @@ function checkOffline() {
264264
}
265265

266266
utils.setInterval(checkOffline, 1000);
267-
window.addEventListener('online', checkOffline);
267+
window.addEventListener('online', () => {
268+
isConnectionDown = false;
269+
checkOffline();
270+
});
268271
window.addEventListener('offline', checkOffline);

src/services/providers/googleDriveAppDataProvider.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,10 @@ export default providerRegistry.register({
8484
});
8585
},
8686
uploadContent(token, content, syncLocation, ifNotTooLate) {
87-
return this.uploadData(token, undefined, content, `${syncLocation.fileId}/content`, ifNotTooLate)
87+
return this.uploadData(token, content, `${syncLocation.fileId}/content`, ifNotTooLate)
8888
.then(() => syncLocation);
8989
},
90-
uploadData(token, sub, item, dataId, ifNotTooLate) {
90+
uploadData(token, item, dataId, ifNotTooLate) {
9191
const syncData = store.getters['data/syncDataByItemId'][dataId];
9292
if (syncData && syncData.hash === item.hash) {
9393
return Promise.resolve();
@@ -98,7 +98,6 @@ export default providerRegistry.register({
9898
id: item.id,
9999
type: item.type,
100100
hash: item.hash,
101-
sub,
102101
}),
103102
['appDataFolder'],
104103
JSON.stringify(item),

src/services/syncSvc.js

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -54,37 +54,33 @@ function cleanSyncedContent(syncedContent) {
5454
}
5555

5656
function applyChanges(changes) {
57-
const token = mainProvider.getToken();
5857
const storeItemMap = { ...store.getters.allItemMap };
5958
const syncData = { ...store.getters['data/syncData'] };
6059
let syncDataChanged = false;
6160

6261
changes.forEach((change) => {
63-
// Ignore items that belong to another user (like settings)
64-
if (!change.item || !change.item.sub || change.item.sub === token.sub) {
65-
const existingSyncData = syncData[change.fileId];
66-
const existingItem = existingSyncData && storeItemMap[existingSyncData.itemId];
67-
if (change.removed && existingSyncData) {
68-
if (existingItem) {
69-
// Remove object from the store
70-
store.commit(`${existingItem.type}/deleteItem`, existingItem.id);
71-
delete storeItemMap[existingItem.id];
72-
}
73-
delete syncData[change.fileId];
74-
syncDataChanged = true;
75-
} else if (!change.removed && change.item && change.item.hash) {
76-
if (!existingSyncData || (existingSyncData.hash !== change.item.hash && (
77-
!existingItem || existingItem.hash !== change.item.hash
78-
))) {
79-
// Put object in the store
80-
if (change.item.type !== 'content') { // Merge contents later
81-
store.commit(`${change.item.type}/setItem`, change.item);
82-
storeItemMap[change.item.id] = change.item;
83-
}
62+
const existingSyncData = syncData[change.fileId];
63+
const existingItem = existingSyncData && storeItemMap[existingSyncData.itemId];
64+
if (change.removed && existingSyncData) {
65+
if (existingItem) {
66+
// Remove object from the store
67+
store.commit(`${existingItem.type}/deleteItem`, existingItem.id);
68+
delete storeItemMap[existingItem.id];
69+
}
70+
delete syncData[change.fileId];
71+
syncDataChanged = true;
72+
} else if (!change.removed && change.item && change.item.hash) {
73+
if (!existingSyncData || (existingSyncData.hash !== change.item.hash && (
74+
!existingItem || existingItem.hash !== change.item.hash
75+
))) {
76+
// Put object in the store
77+
if (change.item.type !== 'content') { // Merge contents later
78+
store.commit(`${change.item.type}/setItem`, change.item);
79+
storeItemMap[change.item.id] = change.item;
8480
}
85-
syncData[change.fileId] = change.syncData;
86-
syncDataChanged = true;
8781
}
82+
syncData[change.fileId] = change.syncData;
83+
syncDataChanged = true;
8884
}
8985
});
9086

@@ -374,7 +370,6 @@ function syncDataItem(dataId) {
374370
}
375371
return mainProvider.uploadData(
376372
token,
377-
dataId === 'settings' ? token.sub : undefined,
378373
mergedItem,
379374
dataId,
380375
);

src/store/modules/modal.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ export default {
6060
resolveText: 'Yes, delete',
6161
rejectText: 'No',
6262
}),
63+
trashDeletion: ({ dispatch }) => dispatch('open', {
64+
content: '<p>Files in the trash are automatically deleted after 7 days of inactivity.</p>',
65+
resolveText: 'Ok',
66+
}),
6367
reset: ({ dispatch }) => dispatch('open', {
6468
content: '<p>This will clean your local files and settings. Are you sure?</p>',
6569
resolveText: 'Yes, clean',

0 commit comments

Comments
 (0)