Skip to content

Commit ddd41db

Browse files
author
djinni-hppro
committed
.
1 parent db4a386 commit ddd41db

2 files changed

Lines changed: 26 additions & 19 deletions

File tree

src/index.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -183,17 +183,17 @@ <h3 class="text-lg font-semibold" x-text="noteEditorNoteId ? ('Editing: #' + not
183183
<div class="flex-grow min-w-0">
184184
<div class="flex justify-between items-baseline mb-2">
185185
<span class="text-xs italic" x-text="formatDate(note.updatedAt)"></span>
186+
<template x-for="provider in ['s3', 'gdrive', 'git', 'ipfs', 'nostr']" :key="provider">
187+
<template x-if="getNoteSyncStatusByProvider(note)[provider]">
188+
<span class="rounded-full p-1 flex items-center justify-center" :title="getProviderName(provider) + ': ' + (getNoteSyncStatusByProvider(note)[provider].status || 'idle')" :class="getProviderSyncIconClass(getNoteSyncStatusByProvider(note)[provider].status || 'idle').color + ' ' + getProviderSyncIconClass(getNoteSyncStatusByProvider(note)[provider].status || 'idle').bg">
189+
<span x-html="getProviderIcon(provider)"></span>
190+
</span>
191+
</template>
192+
</template>
186193
<span class="text-xs font-bold" x-show="note.priority" x-text="'P:' + note.priority"></span>
187194
</div>
188195
<div class="flex items-center gap-2">
189196
<div class="flex gap-1">
190-
<template x-for="provider in ['s3', 'gdrive', 'git', 'ipfs', 'nostr']" :key="provider">
191-
<template x-if="getNoteSyncStatusByProvider(note)[provider]">
192-
<span class="rounded-full p-1 flex items-center justify-center shadow-sm" :title="getProviderName(provider) + ': ' + (getNoteSyncStatusByProvider(note)[provider].status || 'idle')" :class="getProviderSyncIconClass(getNoteSyncStatusByProvider(note)[provider].status || 'idle').color + ' ' + getProviderSyncIconClass(getNoteSyncStatusByProvider(note)[provider].status || 'idle').bg">
193-
<span x-html="getProviderIcon(provider)"></span>
194-
</span>
195-
</template>
196-
</template>
197197
</div>
198198
<h4 class="text-base font-bold truncate" :style="{ 'color': getNoteColor(note) }" x-text="note.title"></h4>
199199
</div>

src/index.js

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,11 @@ document.addEventListener('alpine:init', () => { Alpine.data('mainApp', () => ({
389389
},
390390

391391
getNoteSyncStatus(note) {
392-
return this.noteSyncStatus[note.id] || { status: 'idle', updatedAt: note.updatedAt };
392+
if (this.noteSyncStatus[note.id]) {
393+
return this.noteSyncStatus[note.id];
394+
}
395+
const hasSynced = this.lastSync && (new Date(note.updatedAt) <= new Date(this.lastSync));
396+
return { status: hasSynced ? 'ok' : 'idle', updatedAt: note.updatedAt };
393397
},
394398

395399
getNoteSyncIconClass(status) {
@@ -423,17 +427,17 @@ document.addEventListener('alpine:init', () => { Alpine.data('mainApp', () => ({
423427
getProviderIcon(provider) {
424428
switch(provider) {
425429
case 's3':
426-
return `<svg class="w-3.5 h-3.5" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><ellipse cx="12" cy="5" rx="9" ry="3"></ellipse><path d="M3 5v14c0 1.66 4 3 9 3s9-1.34 9-3V5"></path><path d="M3 12c0 1.66 4 3 9 3s9-1.34 9-3"></path></svg>`;
430+
return `<svg class="w-3 h-3" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><ellipse cx="12" cy="5" rx="9" ry="3"></ellipse><path d="M3 5v14c0 1.66 4 3 9 3s9-1.34 9-3V5"></path><path d="M3 12c0 1.66 4 3 9 3s9-1.34 9-3"></path></svg>`;
427431
case 'gdrive':
428-
return `<svg class="w-3.5 h-3.5" viewBox="0 0 24 24" fill="currentColor"><path d="M8.2 14.28L4.36 21H12.2l3.84-6.72H8.2zm14.1-1.74l-3.84-6.72H10.6l3.84 6.72h7.86zm-5.63.87l-3.84-6.72L5 13.41l3.84 6.72 7.83-6.72z" /></svg>`;
432+
return `<svg class="w-3 h-3" viewBox="0 0 24 24" fill="currentColor"><path d="M8.2 14.28L4.36 21H12.2l3.84-6.72H8.2zm14.1-1.74l-3.84-6.72H10.6l3.84 6.72h7.86zm-5.63.87l-3.84-6.72L5 13.41l3.84 6.72 7.83-6.72z" /></svg>`;
429433
case 'git':
430-
return `<svg class="w-3.5 h-3.5" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><line x1="6" y1="3" x2="6" y2="15"></line><circle cx="18" cy="6" r="3"></circle><circle cx="6" cy="18" r="3"></circle><path d="M18 9a9 9 0 0 1-9 9"></path><circle cx="6" cy="6" r="3"></circle></svg>`;
434+
return `<svg class="w-3 h-3" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><line x1="6" y1="3" x2="6" y2="15"></line><circle cx="18" cy="6" r="3"></circle><circle cx="6" cy="18" r="3"></circle><path d="M18 9a9 9 0 0 1-9 9"></path><circle cx="6" cy="6" r="3"></circle></svg>`;
431435
case 'ipfs':
432-
return `<svg class="w-3.5 h-3.5" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M12 2L2 7v10l10 5 10-5V7L12 2z"></path><path d="M12 22V12"></path><path d="M12 12L2 7"></path><path d="M12 12l10-5"></path></svg>`;
436+
return `<svg class="w-3 h-3" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M12 2L2 7v10l10 5 10-5V7L12 2z"></path><path d="M12 22V12"></path><path d="M12 12L2 7"></path><path d="M12 12l10-5"></path></svg>`;
433437
case 'nostr':
434-
return `<svg class="w-3.5 h-3.5" viewBox="0 0 24 24" fill="currentColor"><path d="M13 2L3 14h9l-1 8 10-12h-9l1-8z" /></svg>`;
438+
return `<svg class="w-3 h-3" viewBox="0 0 24 24" fill="currentColor"><path d="M13 2L3 14h9l-1 8 10-12h-9l1-8z" /></svg>`;
435439
default:
436-
return `<svg class="w-3.5 h-3.5" viewBox="0 0 24 24" fill="currentColor"><circle cx="12" cy="12" r="10" /></svg>`;
440+
return `<svg class="w-3 h-3" viewBox="0 0 24 24" fill="currentColor"><circle cx="12" cy="12" r="10" /></svg>`;
437441
}
438442
},
439443

@@ -470,11 +474,14 @@ document.addEventListener('alpine:init', () => { Alpine.data('mainApp', () => ({
470474

471475
if (!allStatus) {
472476
allStatus = {};
473-
if (this.s3Bucket) allStatus.s3 = { status: 'idle' };
474-
if (this.gdriveStore && this.gdriveStore.connected) allStatus.gdrive = { status: 'idle' };
475-
if (this.gitRepoUrl) allStatus.git = { status: 'idle' };
476-
if (this.useDirectIpfs || this.pinataJwt || this.pinataApiKey) allStatus.ipfs = { status: 'idle' };
477-
if (this.nostrPrivateKey) allStatus.nostr = { status: 'idle' };
477+
const hasSynced = this.lastSync && (new Date(note.updatedAt) <= new Date(this.lastSync));
478+
const defaultStatus = hasSynced ? 'ok' : 'idle';
479+
480+
if (this.s3Bucket) allStatus.s3 = { status: defaultStatus };
481+
if (this.gdriveStore && this.gdriveStore.connected) allStatus.gdrive = { status: defaultStatus };
482+
if (this.gitRepoUrl) allStatus.git = { status: defaultStatus };
483+
if (this.useDirectIpfs || this.pinataJwt || this.pinataApiKey) allStatus.ipfs = { status: defaultStatus };
484+
if (this.nostrPrivateKey) allStatus.nostr = { status: defaultStatus };
478485
return allStatus;
479486
}
480487

0 commit comments

Comments
 (0)