Skip to content

Commit dcf85ba

Browse files
committed
fix annotations not working on extension
1 parent 8e147eb commit dcf85ba

2 files changed

Lines changed: 8 additions & 7 deletions

File tree

extension/src/entrypoints/content.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,13 +200,17 @@ export default defineContentScript({
200200
submitBtn.textContent = 'Posting...';
201201

202202
try {
203-
await sendMessage('createAnnotation', {
203+
const res = await sendMessage('createAnnotation', {
204204
url: window.location.href,
205205
title: document.title,
206206
text,
207207
selector: { type: 'TextQuoteSelector', exact: quoteText },
208208
});
209209

210+
if (!res.success) {
211+
throw new Error(res.error || 'Unknown error');
212+
}
213+
210214
showToast('Annotation created!', 'success');
211215
composeModal?.remove();
212216
composeModal = null;

extension/src/utils/api.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,10 @@ export async function createAnnotation(data: {
132132
const res = await apiRequest('/annotations', {
133133
method: 'POST',
134134
body: JSON.stringify({
135-
target: {
136-
source: data.url,
137-
selector: data.selector,
138-
},
139-
body: { type: 'TextualBody', value: data.text, format: 'text/plain' },
140-
motivation: 'commenting',
135+
url: data.url,
136+
text: data.text,
141137
title: data.title,
138+
selector: data.selector,
142139
}),
143140
});
144141

0 commit comments

Comments
 (0)