stephpy/timeline-bundle

Removing timeline when directComplement object no longer exists

Closed this issue · 9 comments

Hi there,

Is there any easy way of being able to remove/hide from the timeline when the object being used in the directComplement no longer exists. Obviously I get an error when I have removed that, and I have added a condition in my twig template to cover this, but all it advises is that this object has now been removed.

For example if I have a timeline that says the following:

Paul Pounder updated This is a test Blog article.

If I delete the Blog Article the link to that article is still in the timeline_component table and therefore I get an error when the timeline renders. I need an easy way of being able to remove this and it's equivelant records in the database, or not render the timeline if it no longer exists.

Hope you can help.
Regards
Paul

Hi, yep, it's already done.

See options filter_unresolved on DataHydrator

You should read this part

It removes from timeline results actions with a component not resolved (which not exists).

Regards

Brilliant. Thanks again. I guess I should try and read the whole manual :-)

You're welcome ;)

Hi Stephane,

Think I may have found an issue. (Or it could just be me again). I have two timelines referring to the same directComplement.

For example:
Paul Pounder created "a blog article"
Paul Pounder updated "a blog article"

I then delete "a blog article"

The filter does work, but only hides the last timeline item against that action. So I am still getting "created a blog article" in my timeline stream. Updated a blog article does get hidden. Both are created in the same way

[User Object] verb [directComplement - Article Object]

I've looked at the code, and it seems to be around line 135 of Spy/Timeline/Filter/DataHydrator:

$unset($items[$key])

I am using a Paginator (KNP) so it is an instance of PagerInterface.

Have you any thoughts?
Regards
Paul

My current solution to remove a directComplement:

$actionManager   = $this->get('spy_timeline.action_manager');
$timelineManager = $this->get('spy_timeline.timeline_manager');
$subject = $actionManager->findOrCreateComponent('a\model', 1);

$action = $actionManager->getQueryBuilderForComponent($subject)->getQuery()->getSingleResult();
$this->getDoctrine()->getManager()->remove($action);

$timelineManager->removeAll($subject, array('context' => 'FEED'));
$timelineManager->removeAll($subject, array('context' => 'GLOBAL'));
$timelineManager->flush();

@ppounder

It should not be possible. If you removed “a blog article“. How it returns you Paul Pounder created "a blog article" ?

Is that still the case if you have two links to the same directComplement in the actionComponent? Will filter_unresolved hide all timeline's to the removed directComplement?

As my example above, I have
Paul Pounder created "blog article"
and
Paul Pounder updated "blog article"

It may be the way I have this set up, but the filter_unresolved is removing/hiding the 'updated' but not the 'created'. I can certainly use @Zeichen32 solution as a workaround.

Cheers again for your help, I do love this bundle.

Apologies, it is working. I've toggled the filter_unresolved to false and true. What I have found is that when it does hide an unresolved, it still counts that item in the paginator.

I am still having a few issues, but I don't think this is around the bundle. From my perspective, if I delete a Blog Article then I'm going to delete any timeline records referring to it so I will try and build @Zeichen32 workaround into my delete action.

Thanks again. Will close this as it's not bundle related.

Yes @ppounder,if you get 10 items and 2 are removed via filter_unresolved option, you'll have only 8 items.

At this moment there is no solution via the bundle, @Zeichen32 solution is OK, if you want to everytime have 10 items, you should remove action with removed components.