Skip to content
This repository was archived by the owner on Aug 27, 2025. It is now read-only.

Commit df6db78

Browse files
committed
fix: syncing status
1 parent 59d688a commit df6db78

3 files changed

Lines changed: 49 additions & 3 deletions

File tree

src/components/Notes.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
<template>
22
<el-card class="relative border-0 hover:bg-gray-100" shadow="never">
33
<div class="flex flex-row">
4-
<div class="w-10 h-10 mr-3"><img class="rounded-full" :src="profile.avatars?.[0]" /></div>
5-
<div>
4+
<div class="w-10 h-10 mr-3" v-if="profile.avatars?.[0]">
5+
<img class="rounded-full" :src="profile.avatars?.[0]" />
6+
</div>
7+
<div class="flex-1">
68
<div class="mb-1">
79
<span class="font-bold align-middle">{{ profile.name || profile.username }}</span>
810
<span class="text-gray-500 ml-1 align-middle" v-if="profile.username">@{{ profile.username }}</span>

src/components/SyncStatus.vue

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ const props = defineProps({
3333
type: Function,
3434
required: true,
3535
},
36+
link: {
37+
type: String,
38+
required: true,
39+
},
3640
});
3741
3842
const note = ref<Note>();
@@ -57,8 +61,34 @@ const syncOrRedirect = async (e: any) => {
5761
5862
const init = async () => {
5963
note.value = await props.getNote();
60-
loading.value = false;
64+
if (loadingNotice.value !== 'Syncing...') {
65+
loading.value = false;
66+
}
6167
};
6268
6369
init();
70+
71+
async function setStatus(status: string) {
72+
switch (status) {
73+
case 'syncing':
74+
loading.value = true;
75+
loadingNotice.value = 'Syncing...';
76+
break;
77+
case 'synced':
78+
loadingNotice.value = 'Loading...';
79+
init();
80+
break;
81+
}
82+
}
83+
84+
if (!(<any>window).cssc) {
85+
(<any>window).cssc = {};
86+
}
87+
if (!(<any>window).cssc.updateSyncing) {
88+
(<any>window).cssc.updateSyncing = {};
89+
}
90+
(<any>window).cssc.updateSyncing[props.link] = setStatus;
91+
if ((<any>window).cssc.syncing === props.link) {
92+
setStatus('syncing');
93+
}
6494
</script>

src/content-script/hooks/twitter.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,13 @@ class TwitterHook {
117117
}
118118

119119
private async sync(note: NoteInput, attachmentUrls?: string[]) {
120+
if (!(<any>window).cssc) {
121+
(<any>window).cssc = {};
122+
}
123+
const url = note.related_urls?.[0];
124+
(<any>window).cssc.syncing = url;
125+
(<any>window).cssc.updateSyncing?.[url || '']?.('syncing');
126+
120127
const settings = await getSettings();
121128
const handle = settings.handle;
122129
const syncing = settings.syncing;
@@ -157,13 +164,19 @@ class TwitterHook {
157164
} catch (e) {
158165
this.main.xlog('error', 'Failed to post note.', e);
159166
ElMessage.error('CrossSync encountered a problem: Unidata failed to post note.');
167+
168+
(<any>window).cssc.syncing = null;
169+
(<any>window).cssc.updateSyncing?.[url || '']?.('synced');
160170
}
161171
} else {
162172
this.main.xlog('info', `Failed to get Unidata Instance.`);
163173
ElMessage.error('CrossSync encountered a problem: Unidata instance is not ready.');
164174
}
165175

166176
notice?.close();
177+
178+
(<any>window).cssc.syncing = null;
179+
(<any>window).cssc.updateSyncing?.[url || '']?.('synced');
167180
}
168181
}
169182

@@ -281,6 +294,7 @@ class TwitterHook {
281294
),
282295
].filter((url) => !!url) as string[];
283296
const syncStatus = createApp(SyncStatus, {
297+
link: link,
284298
getNote: async () => {
285299
if (this.noteCache.has(link)) {
286300
return this.noteCache.get(link);

0 commit comments

Comments
 (0)