diff --git a/app/ExportResources/Contact/Contact.php b/app/ExportResources/Contact/Contact.php
index 1ca6a45d9da..359ee7976fb 100644
--- a/app/ExportResources/Contact/Contact.php
+++ b/app/ExportResources/Contact/Contact.php
@@ -46,7 +46,6 @@ public function data(): ?array
'avatar_source' => $this->avatar_source,
'avatar_gravatar_url' => $this->avatar_gravatar_url,
'avatar_adorable_uuid' => $this->avatar_adorable_uuid,
- 'avatar_adorable_url' => $this->avatar_adorable_url,
'avatar_default_url' => $this->avatar_default_url,
$this->mergeWhen($this->avatarPhoto !== null, function () {
return ['avatar_photo' => $this->avatarPhoto->uuid];
diff --git a/app/Models/Contact/Contact.php b/app/Models/Contact/Contact.php
index d36558e5bb0..299b7e32919 100644
--- a/app/Models/Contact/Contact.php
+++ b/app/Models/Contact/Contact.php
@@ -90,7 +90,7 @@ class Contact extends Model
'is_partial',
'is_starred',
'avatar_source',
- 'avatar_adorable_url',
+ 'avatar_adorable_uuid',
'avatar_gravatar_url',
'avatar_default_url',
'avatar_photo_id',
@@ -1121,26 +1121,10 @@ public function getAvatarDefaultURL()
* @param string|null $value
* @return string|null
*/
- public function getAvatarAdorableUrlAttribute(?string $value): ?string
+ public function getAvatarAdorableDataUrlAttribute(?string $value): ?string
{
- if (isset($value) && $value !== '') {
- $url = Str::of($value)
- ->after('https://api.adorable.io/avatars/')
- ->ltrim('/');
-
- $data = Str::of($url)->split('/\//');
-
- if (! ctype_digit($data[0]) || count($data) === 1) {
- $size = config('monica.avatar_size');
- $hash = $data[0];
- } else {
- $size = (int) $data[0];
- $hash = $data[1];
- }
-
- $hash = Str::of($hash)->split('/\.png/')[0];
-
- return LaravelAdorable::get($size, $hash);
+ if (isset($this->avatar_adorable_uuid) && $this->avatar_adorable_uuid !== '') {
+ return LaravelAdorable::get(config('monica.avatar_size'), $this->avatar_adorable_uuid);
}
return null;
@@ -1162,7 +1146,7 @@ public function getAvatarURL()
switch ($this->avatar_source) {
case 'adorable':
- $avatarURL = $this->avatar_adorable_url;
+ $avatarURL = $this->avatar_adorable_data_url;
break;
case 'gravatar':
$avatarURL = $this->avatar_gravatar_url;
diff --git a/resources/js/components/people/ContactList.vue b/resources/js/components/people/ContactList.vue
index a7a09b4f128..bc9f33d89d5 100644
--- a/resources/js/components/people/ContactList.vue
+++ b/resources/js/components/people/ContactList.vue
@@ -80,7 +80,7 @@
- {{ props.row.complete_name }}
+ {{ props.row.complete_name }}
- {{ props.row.complete_name }}
+ {{ props.row.complete_name }}
diff --git a/resources/js/components/people/partials/ContactAutosuggest.vue b/resources/js/components/people/partials/ContactAutosuggest.vue
index 05585ed41e9..c95acef9ee2 100644
--- a/resources/js/components/people/partials/ContactAutosuggest.vue
+++ b/resources/js/components/people/partials/ContactAutosuggest.vue
@@ -173,7 +173,7 @@ export default {
needle: keyword
}).then(function(response) {
const data = [];
- if (response.data.noResults === null) {
+ if (response.data.noResults === undefined || response.data.noResults === null) {
response.data.data
.forEach(function (contact) {
contact.keyword = keyword;
diff --git a/resources/views/people/avatar/edit.blade.php b/resources/views/people/avatar/edit.blade.php
index 26adb209c39..23669dc1a57 100644
--- a/resources/views/people/avatar/edit.blade.php
+++ b/resources/views/people/avatar/edit.blade.php
@@ -19,7 +19,7 @@
mock(LaravelAdorable::class, function (MockInterface $mock) {
- $mock->shouldReceive('get')->andReturn('adorableURL');
- });
-
// default
$contact = factory(Contact::class)->create([
'avatar_default_url' => 'defaultURL',
@@ -534,10 +530,14 @@ public function it_returns_the_url_of_the_avatar()
// adorable
$contact = factory(Contact::class)->create([
- 'avatar_adorable_url' => 'adorableURL',
+ 'avatar_adorable_uuid' => 'uuid',
'avatar_source' => 'adorable',
]);
+ $this->mock(LaravelAdorable::class, function (MockInterface $mock) {
+ $mock->shouldReceive('get')->andReturn('adorableURL');
+ });
+
$this->assertEquals(
'adorableURL',
$contact->getAvatarURL()