Skip to content
This repository has been archived by the owner on Jun 16, 2021. It is now read-only.

Commit

Permalink
closed #123 fixed keyword-filtered items that weren't filtered out at…
Browse files Browse the repository at this point in the history
… the category dropdown
  • Loading branch information
Kaishiyoku committed Jan 2, 2020
1 parent c5b30c3 commit 9ff41cf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions app/Http/Controllers/FeedController.php
Expand Up @@ -23,7 +23,7 @@ public function category($id)
{
// check if there are any unread feed items
$unreadFeedItemsCount = auth()->user()->feeds()->whereCategoryId($id)->withCount(['feedItems' => function ($query) {
return $query->unread();
return $query->unread()->keywordFiltered(auth()->user());
}])->get()->reduce(function ($carry, Feed $feed) {
return $carry + $feed->feed_items_count;
}, 0);
Expand All @@ -37,7 +37,7 @@ public function category($id)

public function history()
{
$totalCountReadFeedItems = auth()->user()->feedItems()->read()->count();
$totalCountReadFeedItems = auth()->user()->feedItems()->read()->keywordFiltered(auth()->user())->count();
$readFeedItems = auth()->user()->feedItems()->read()->keywordFiltered(auth()->user())->with('categories')->paginate(env('NUMBER_OF_ITEMS_PER_PAGE'));

return view('feed.history', compact('totalCountReadFeedItems', 'readFeedItems'));
Expand All @@ -59,15 +59,15 @@ public function markAllAsRead($categoryId = null)
if (env('DEFERRED_MARK_AS_READ') && $unreadFeedItems->count() > $minNumber) {
$unreadFeedItems = new ManualPaginator($unreadFeedItems->get(), (int) env('DEFERRED_PER_PAGE'));

foreach($unreadFeedItems->pages() as $items) {
$unreadFeedItems->pages()->each(function ($items) use ($date) {
ProcessFeedItems::dispatch($items, $date);
}
});
} else {
foreach ($unreadFeedItems->get() as $feedItem) {
$unreadFeedItems->get()->each(function ($feedItem) use ($date) {
$feedItem->read_at = $date;

$feedItem->save();
}
});
}

flash()->success(__('feed.mark_all_as_read.success'));
Expand Down Expand Up @@ -136,7 +136,7 @@ public function searchResult(Request $request)
->get()
->pluck('id');

$foundFeedItemsFromIndex = FeedItem::whereIn('id', $foundFeedItemIdsFromIndex)
$foundFeedItemsFromIndex = FeedItem::keywordFiltered(auth()->user())->whereIn('id', $foundFeedItemIdsFromIndex)
->whereIn('feed_id', $feedIds);

if ($dateFrom) {
Expand Down Expand Up @@ -212,7 +212,7 @@ private function baseIndex($categoryId = null)

$categories = auth()->user()->categories()->with(['feeds' => function ($query) {
return $query->withCount(['feedItems' => function ($query) {
return $query->unread();
return $query->unread()->keywordFiltered(auth()->user());
}]);
}])->get();

Expand Down
4 changes: 2 additions & 2 deletions app/helpers.php
Expand Up @@ -96,10 +96,10 @@ function syncFeedItemCategories(Collection $categoryTitles, User $user, FeedItem

if (! function_exists('createDateFromStr')) {
/**
* @param string $str
* @param string|null $str
* @return Carbon|null
*/
function createDateFromStr(string $str): ?Carbon
function createDateFromStr(?string $str): ?Carbon
{
try {
return Carbon::createFromFormat(__('common.date_formats.date'), $str)->startOfDay();
Expand Down

0 comments on commit 9ff41cf

Please sign in to comment.