[MODULE][Left][UI][TAGS] Add Left module which handles fetching tags and followers, fix self tags

This commit is contained in:
Hugo Sales
2020-08-15 06:08:52 +00:00
committed by Hugo Sales
parent 31ccb2d07b
commit d548dc9284
4 changed files with 52 additions and 9 deletions

View File

@@ -222,14 +222,14 @@ class GSActor extends Entity
return DB::findBy('gsactor_tag', ['tagger' => $this->id, 'tagged' => $this->id]);
}
public function setSelfTags(array $tags, array $pt_existing): void
public function setSelfTags(array $tags, array $existing): void
{
$tag_existing = F\map($pt_existing, function ($pt) { return $pt->getTag(); });
$tag_existing = F\map($existing, function ($pt) { return $pt->getTag(); });
$tag_to_add = array_diff($tags, $tag_existing);
$tag_to_remove = array_diff($tag_existing, $tags);
$pt_to_remove = F\filter($pt_existing, function ($pt) use ($tag_to_remove) { return in_array($pt->getTag(), $tag_to_remove); });
$pt_to_remove = F\filter($existing, function ($pt) use ($tag_to_remove) { return in_array($pt->getTag(), $tag_to_remove); });
foreach ($tag_to_add as $tag) {
$pt = new GSActorTag($this->id, $this->id, $tag);
$pt = GSActorTag::create(['tagger' => $this->id, 'tagged' => $this->id, 'tag' => $tag]);
DB::persist($pt);
}
foreach ($pt_to_remove as $pt) {

View File

@@ -19,6 +19,7 @@
namespace App\Entity;
use App\Core\Entity;
use DateTimeInterface;
/**
@@ -35,7 +36,7 @@ use DateTimeInterface;
* @copyright 2020 Free Software Foundation, Inc http://www.fsf.org
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
class GSActorTag
class GSActorTag extends Entity
{
// {{{ Autocode