Skip to content

Commit

Permalink
Fetch annotations from the server
Browse files Browse the repository at this point in the history
  • Loading branch information
jo-es committed Aug 1, 2020
1 parent ae824d0 commit f64338d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
5 changes: 2 additions & 3 deletions public/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,13 @@ async function onDidReceiveMessage(event) {
if (event.data.type && (event.data.type === 'QUERY_PUBLISHER')) {
try {
const response = await fetch(event.data.url);
console.log(response);
// console.log(response);
if (response.status !== 200) { throw new Error(response); }
try {
const result = await response.json();
console.log(result);
// console.log(result);
window.postMessage({ type: 'QUERY_PUBLISHER_RESPONSE', result }, '*');
} catch (error) {
console.log(error);
console.log(error);
throw new Error('Response body is empty.')
}
Expand Down
15 changes: 8 additions & 7 deletions src/Components/Reader.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@ const Reader = ({ setPage }) => {
useEffect(() => {
(async () => {
const { tweetId, tweetAuthor } = getTweetData()
const annotationCIDs = await getAnnotationCIDsByReference({ reference: tweetId });
// const annotationCIDs = await getAnnotationCIDsByReference({ reference: tweetId });
// const annotations = [];
// for (const annotationCID of annotationCIDs) {
// annotations.push(new Annotation({ payload: await getAnnotationData(annotationCID) }));
// }
const annotations = [];
for (const annotationCID of annotationCIDs) {
annotations.push(new Annotation({ payload: await getAnnotationData(annotationCID) }));
const annotationsFromPublisher = await getAnnotationsByReference({ reference: tweetId });
for (const annotation of annotationsFromPublisher) {
annotations.push(new Annotation({ payload: annotation }));
}
// combine perisisted and pending annotations
// const annotationsFromPublisher = await getAnnotationsByReference({ reference: tweetId });
// console.log(annotations);
// console.log(annotationsFromPublisher);
setTweetAnnotations(annotations);
})();
}, [])
Expand Down
3 changes: 2 additions & 1 deletion src/services/publisher.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// const PUBLISHER_URL = 'https://pan.network/annotation/v1';
const PUBLISHER_URL = 'https://134.122.90.29:8000';
// const PUBLISHER_URL = 'https://134.122.90.29:8000';
const PUBLISHER_URL = 'https://annotations.network/annotations';


async function get(params) {
Expand Down

0 comments on commit f64338d

Please sign in to comment.