(link: SyncLinkItem)
| 100 | } |
| 101 | |
| 102 | private async processLink(link: SyncLinkItem) { |
| 103 | this.log.debug('syncing link', link) |
| 104 | |
| 105 | const matchingResources = await this.resourceManager.getResourcesFromSourceURL(link.url) |
| 106 | let bookmarkedResource = matchingResources.find( |
| 107 | (resource) => |
| 108 | resource.type !== ResourceTypes.ANNOTATION && resource.type !== ResourceTypes.HISTORY_ENTRY |
| 109 | ) |
| 110 | |
| 111 | if (bookmarkedResource) { |
| 112 | this.log.debug('found existing bookmarked resource', bookmarkedResource) |
| 113 | return null |
| 114 | } |
| 115 | |
| 116 | const date = new Date(link.timestamp) |
| 117 | |
| 118 | const parsed = await extractAndCreateWebResource( |
| 119 | this.resourceManager, |
| 120 | link.url, |
| 121 | { |
| 122 | sourceURI: link.url |
| 123 | }, |
| 124 | [ |
| 125 | ResourceTag.canonicalURL(link.url), |
| 126 | ResourceTag.import(), |
| 127 | ResourceTag.viewedByUser(false), |
| 128 | ...(link.timestamp ? [ResourceTag.sourcePublishedAt(date.toISOString())] : []) |
| 129 | ] |
| 130 | ) |
| 131 | |
| 132 | return parsed.resource |
| 133 | } |
| 134 | |
| 135 | async sync() { |
| 136 | let toast: Toast | null = null |
no test coverage detected