Change the callback in KnownActors to use the same format as KnownActivities

This commit is contained in:
Feufochmar 2020-03-30 12:49:43 +02:00
parent 8056398b64
commit 2c7f09f926
2 changed files with 9 additions and 8 deletions

View File

@ -20,9 +20,9 @@ Activity.prototype = {
const profile = this.raw.actor
KnownActors.retrieve(
profile,
function(load_ok, failure_message) {
function(load_ok, actor, failure_message) {
if (load_ok) {
this.actor = KnownActors.get(profile)
this.actor = actor
}
// Load the actors in the "to" array, skip to "cc" if there is no "to", and stop is there is no "cc" either
if (this.raw.to) {
@ -48,9 +48,9 @@ Activity.prototype = {
const profile = next.value
KnownActors.retrieve(
profile,
function(load_ok, failure_message) {
function(load_ok, actor, failure_message) {
if (load_ok) {
this.to.push(KnownActors.get(profile))
this.to.push(actor)
} else {
// Collection ?
}
@ -67,9 +67,9 @@ Activity.prototype = {
const profile = next.value
KnownActors.retrieve(
profile,
function(load_ok, failure_message) {
function(load_ok, actor, failure_message) {
if (load_ok) {
this.cc.push(KnownActors.get(profile))
this.cc.push(actor)
} else {
// Collection ?
}

View File

@ -18,16 +18,17 @@ const KnownActors = {
}
},
// Retrieve an actor
// Callback takes three arguments: load_ok, retrieved_actor, failure_message
retrieve: function(profile, callback) {
if (KnownActors.get(profile)) {
callback(true, undefined)
callback(true, KnownActors.get(profile), undefined)
} else {
const actor = new Actor()
actor.loadFromProfileUrl(
profile,
function(load_ok, failure_message) {
KnownActors.set(profile, actor) // in case of failure, actor is not valid
callback(load_ok, failure_message)
callback(load_ok, actor, failure_message)
})
}
}