gancio-upstream/plugins/formatter.js

26 lines
No EOL
866 B
JavaScript

export default ({ app, store }, inject) => {
const formatter = {
actor (actor, context='label') {
if (context === 'title') {
if (actor?.ap_id) {
return actor?.object?.name
} else {
return 'Local Instance'
}
} else if (context === 'label' || context === 'filter') {
if (actor?.ap_id) {
return `@${actor?.object?.preferredUsername ?? actor?.name}@${actor?.instanceDomain ?? actor?.domain}`
} else {
return `@${store?.state?.settings?.instance_name}@${store?.state?.settings?.hostname}`
}
} else if (context === 'icon') {
if (actor?.ap_id) {
return actor?.object?.icon?.url ?? `${item.url}/favicon.ico`
} else {
return store.state.settings.baseurl + '/logo.png'
}
}
}
}
inject('format', formatter)
}