Skip to content

Commit

Permalink
refactor: ingestNote invocation to optimize performance
Browse files Browse the repository at this point in the history
  • Loading branch information
akhileshthite committed Jun 6, 2024
1 parent 2ee7132 commit fce66f0
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions db.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,12 @@ export class ActivityPubDB extends EventTarget {
async getNote (url) {
try {
const note = await this.db.get(NOTES_STORE, url)
if (!note) throw new Error('Not loaded')
return note
} catch {
if (!note) throw new Error('Note not loaded')
return note // Simply return the locally found note.
} catch (error) {
// If the note is not in the local store, fetch it but don't automatically ingest it.
const note = await this.#get(url)
await this.ingestNote(note)
return note
return note // Return the fetched note for further processing by the caller.
}
}

Expand Down

0 comments on commit fce66f0

Please sign in to comment.