Created
February 5, 2021 11:15
-
-
Save cdharris/ee5b2dd90cdb4adf9b88da65f4373790 to your computer and use it in GitHub Desktop.
Memex Multi-content api explorations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Indexer { | |
constructor(private storage, private tabManager) {} | |
async ensureIndexed(query: MetadataQuery) { | |
// Query the storage database, perhaps a cache first too to check if the query corrosponds to content already saved | |
if (record) { | |
return ContentMetadata(record) | |
} else { | |
// Ask the tab manager if it knows of a content currently open by that `query` | |
// If so do the full text database indexing | |
// wait for that (optional, could also schedule that for the bg) | |
// return the UUID | |
return ContentMetadata(createdRecord) | |
} | |
} | |
} | |
class TagRepository { | |
constructor(private storage,private indexer) {} | |
async addContentTagByQuery(query: MetadataQuery, tagId) { | |
const uuid = await indexer.ensureIndexed(query) | |
return storage.addContentTag(uuid,tagId) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment