2024-11-12 14:10:24 +01:00
|
|
|
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) {
|
2024-12-06 15:21:49 +01:00
|
|
|
return actor?.object?.icon?.url ?? `${actor?.instanceDomain ?? actor?.domain ?? '' }/favicon.ico`
|
2024-11-12 14:10:24 +01:00
|
|
|
} else {
|
|
|
|
return store.state.settings.baseurl + '/logo.png'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
inject('format', formatter)
|
|
|
|
}
|