XF 2.0 How does notices leave out notices that are dismissed by the user

Matt C.

Well-known member
I am wondering how the notice list leaves out notices that are dismissed by the user. I looked in notice repository and some other places, but can't find it.

Any help would be great. Thank you.
 
Dismissed notices are in the user's session info...

Look at..
XF/Pub/App->updateUserCaches
&
XF/Pub/App->getNoticeList
 
Dismissed notices are in the user's session info...

Look at..
XF/Pub/App->updateUserCaches
&
XF/Pub/App->getNoticeList

So is this the right way to extend the App?
Code:
<?php

namespace AH\FeaturedThreads\XF\Pub;

use XF\Container;
use XF\HTTP\Response;
use XF\Mvc\Renderer\AbstractRenderer;
use XF\Mvc\Reply\AbstractReply;

class App extends \XF\App
{
    protected $preLoadLocal = [
        'featuredThreads',
        'featuredThreadsLastReset'
    ];

    protected function updateUserCaches()
    {
        $visitor = \XF::visitor();
        $session = $this->session();

        if (!$visitor->user_id)
        {
            return;
        }
        
        if (!$session->keyExists('dismissedFeaturedThreads'))
        {
            $updateDismissed = true;
        }
        else
        {
            $sessionLastFeaturedThreadUpdate = intval($session->get('lastFeaturedThreadUpdate'));
            $dbLastFeaturedThreadReset = $this->get('featuredThreads.lastReset');
            $updateDismissed = ($dbLastFeaturedThreadReset > $sessionLastFeaturedThreadUpdate);
        }

        if ($updateDismissed)
        {
            $session->dismissedFeaturedThreads = $this->repository('AH\FeaturedThreads:FeaturedThread')->getDismissedFeaturedThreadsForUser($visitor);
            $session->lastFeaturedThreadUpdate = \XF::$time;
        }
    }

    protected function renderPageHtml($content, array $params, AbstractReply $reply, AbstractRenderer $renderer)
    {
        $params['featuredThreads'] = $this->getFeaturedThreadList($params)->getFeaturedThreads();

        $this->fire('app_pub_render_page', [$this, &$params, $reply, $renderer]);

        return $templater->renderTemplate($templateName, $params);
    }

    protected function getFeaturedThreadList(array $pageParams)
    {
        $class = $this->extendClass('AH\FeaturedThreads\FeaturedThreadList');
        /** @var \AH\FeaturedThreads\FeaturedThread $noticeList */
        $featuredThreadList = new $class($this, \XF::visitor(), $pageParams);

        $dismissedFeaturedThreads = $this->session()->dismissedFeaturedThreads;
        if ($dismissedFeaturedThreads)
        {
            $featuredThreadsList->setDismissed($dismissedFeaturedThreads);
        }
        
        foreach ($this->container('featuredThreads') AS $key => $featuredThread)
        {
            $featuredThreadList->addConditionalFeaturedThread($key, $featuredThread);
        }
        
        $this->fire('featuredThreads_setup', [$this, $featuredThreadList, $pageParams]);

        return $featuredThreadList;
    }
}

And then do this:
Screenshot (20).webp
 
Top Bottom