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

Commit dccfacc

Browse files
committed
feat: get note links in sync status btn
1 parent 3cc2f82 commit dccfacc

2 files changed

Lines changed: 22 additions & 18 deletions

File tree

src/components/SyncStatus.vue

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
<template>
2-
<el-tooltip placement="left" :content="loading ? loadingNotice : noteID || 'Click to sync'">
2+
<el-tooltip
3+
placement="top"
4+
:content="loading ? loadingNotice : note ? 'Click to view on Crossbell' : 'Click to sync to Crossbell'"
5+
>
36
<div
47
class="flex w-6 h-6"
58
:class="{
6-
'fill-[#5088ff]': noteID,
7-
grayscale: !noteID,
9+
'fill-[#5088ff]': note,
10+
grayscale: !note,
811
'opacity-50 mr-4': true,
912
}"
1013
cssc="sync-status"
@@ -22,32 +25,38 @@ import { ref } from 'vue';
2225
import { Loading } from '@element-plus/icons-vue';
2326
2427
const props = defineProps({
25-
loadFunc: {
28+
getNote: {
2629
type: Function,
2730
required: true,
2831
},
29-
postFunc: {
32+
postNote: {
3033
type: Function,
3134
required: true,
3235
},
3336
});
3437
35-
const noteID = ref('');
38+
const note = ref<Note>();
3639
const loading = ref(true);
3740
const loadingNotice = ref('Loading...');
3841
3942
const syncOrRedirect = async (e: any) => {
4043
loading.value = true;
4144
e.preventDefault();
42-
if (!noteID.value) {
45+
if (!note.value) {
4346
loadingNotice.value = 'Syncing...';
44-
noteID.value = await props.postFunc();
47+
await props.postNote();
48+
note.value = await props.getNote();
49+
} else {
50+
const scan = note.value.related_urls?.find((url) => url.startsWith('https://scan.crossbell.io/tx/'));
51+
if (scan) {
52+
window.open(scan, '_blank');
53+
}
4554
}
4655
loading.value = false;
4756
};
4857
4958
const init = async () => {
50-
noteID.value = await props.loadFunc();
59+
note.value = await props.getNote();
5160
loading.value = false;
5261
};
5362

src/content-script/hooks/twitter.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,6 @@ class TwitterHook {
141141

142142
if (data.code !== 0) {
143143
ElMessage.error(`CrossSync encountered a problem: ${data.message}`);
144-
} else {
145-
return data.data;
146144
}
147145
} catch (e) {
148146
this.main.xlog('error', 'Failed to post note.', e);
@@ -270,7 +268,7 @@ class TwitterHook {
270268
// .map(video => video.getAttribute('src')), // Not downloadable
271269
].filter((url) => !!url) as string[];
272270
const syncStatus = createApp(SyncStatus, {
273-
loadFunc: async () => {
271+
getNote: async () => {
274272
// Check if it's already synced
275273
const unidata = await this.main.getUnidata();
276274
const noteResp = await unidata?.notes.get({
@@ -279,9 +277,9 @@ class TwitterHook {
279277
url: link,
280278
},
281279
});
282-
return noteResp?.list?.[0]?.id || '';
280+
return noteResp?.list[0];
283281
},
284-
postFunc: async () => {
282+
postNote: async () => {
285283
let newNoteID = '';
286284

287285
const note = {
@@ -295,10 +293,7 @@ class TwitterHook {
295293
related_urls: [link],
296294
};
297295

298-
const data = await this.sync(note, tweetMedia);
299-
newNoteID = data || '';
300-
301-
return newNoteID;
296+
await this.sync(note, tweetMedia);
302297
},
303298
});
304299
syncStatus.use(ElementPlus);

0 commit comments

Comments
 (0)