Skip to content

Commit

Permalink
Merge pull request #3899 from Roardom/modularize-torrent-layout
Browse files Browse the repository at this point in the history
(Refactor) Move user torrent layout query into torrent search component
  • Loading branch information
HDVinnie committed Jun 4, 2024
2 parents ce46fc9 + 391e1f1 commit 87ef0e7
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 65 deletions.
11 changes: 10 additions & 1 deletion app/Http/Livewire/TorrentSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,14 +214,23 @@ class TorrentSearch extends Component
#[Url(history: true)]
public string $sortDirection = 'desc';

#[Url(history: true)]
#[Url(except: 'list')]
public string $view = 'list';

final public function mount(Request $request): void
{
if ($request->missing('sortField')) {
$this->sortField = auth()->user()->settings?->torrent_sort_field ?? 'bumped_at';
}

if ($request->missing('view')) {
$this->view = match (auth()->user()->settings?->torrent_layout) {
1 => 'card',
2 => 'group',
3 => 'poster',
default => 'list',
};
}
}

final public function updating(string $field, mixed &$value): void
Expand Down
27 changes: 2 additions & 25 deletions resources/views/partials/top_nav.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,7 @@
</div>
<ul class="top-nav__main-menus" x-bind:class="expanded && 'mobile'">
<li class="top-nav--left__list-item top-nav__dropdown">
<a
class="top-nav__dropdown--nontouch"
href="{{
route('torrents.index', [
'view' => match (auth()->user()->settings?->torrent_layout) {
1 => 'card',
2 => 'group',
3 => 'poster',
default => 'list',
},
])
}}"
>
<a class="top-nav__dropdown--nontouch" href="{{ route('torrents.index') }}">
<div class="top-nav--left__container">
{{ __('torrent.torrents') }}
</div>
Expand All @@ -32,18 +20,7 @@ class="top-nav__dropdown--nontouch"
</a>
<ul>
<li>
<a
href="{{
route('torrents.index', [
'view' => match (auth()->user()->settings?->torrent_layout) {
1 => 'card',
2 => 'group',
3 => 'poster',
default => 'list',
},
])
}}"
>
<a href="{{ route('torrents.index') }}">
<i class="{{ config('other.font-awesome') }} fa-download"></i>
{{ __('torrent.torrents') }}
</a>
Expand Down
14 changes: 1 addition & 13 deletions resources/views/rss/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,7 @@

@section('nav-tabs')
<li class="nav-tabV2">
<a
class="nav-tab__link"
href="{{
route('torrents.index', [
'view' => match (auth()->user()->settings?->torrent_layout) {
1 => 'card',
2 => 'group',
3 => 'poster',
default => 'list',
},
])
}}"
>
<a class="nav-tab__link" href="{{ route('torrents.index') }}">
{{ __('torrent.search') }}
</a>
</li>
Expand Down
14 changes: 1 addition & 13 deletions resources/views/top10/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,7 @@

@section('nav-tabs')
<li class="nav-tabV2">
<a
class="nav-tab__link"
href="{{
route('torrents.index', [
'view' => match (auth()->user()->settings?->torrent_layout) {
1 => 'card',
2 => 'group',
3 => 'poster',
default => 'list',
},
])
}}"
>
<a class="nav-tab__link" href="{{ route('torrents.index') }}">
{{ __('common.search') }}
</a>
</li>
Expand Down
14 changes: 1 addition & 13 deletions resources/views/torrent/create.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,7 @@

@section('nav-tabs')
<li class="nav-tabV2">
<a
class="nav-tab__link"
href="{{
route('torrents.index', [
'view' => match (auth()->user()->settings?->torrent_layout) {
1 => 'card',
2 => 'group',
3 => 'poster',
default => 'list',
},
])
}}"
>
<a class="nav-tab__link" href="{{ route('torrents.index') }}">
{{ __('torrent.search') }}
</a>
</li>
Expand Down

0 comments on commit 87ef0e7

Please sign in to comment.