diff --git a/app/Enums/PlatformEnum.php b/app/Enums/PlatformEnum.php index 50e1c96..0d8331a 100644 --- a/app/Enums/PlatformEnum.php +++ b/app/Enums/PlatformEnum.php @@ -5,4 +5,18 @@ enum PlatformEnum: string { case LEMMY = 'lemmy'; + + public function channelLabel(): string + { + return match ($this) { + self::LEMMY => 'Community', + }; + } + + public function channelLabelPlural(): string + { + return match ($this) { + self::LEMMY => 'Communities', + }; + } } diff --git a/app/Livewire/Routes.php b/app/Livewire/Routes.php index f679bbc..485a06b 100644 --- a/app/Livewire/Routes.php +++ b/app/Livewire/Routes.php @@ -161,7 +161,7 @@ public function deleteKeyword(int $keywordId): void public function render(): \Illuminate\Contracts\View\View { - $routes = Route::with(['feed', 'platformChannel']) + $routes = Route::with(['feed', 'platformChannel.platformInstance']) ->orderBy('priority', 'desc') ->get(); @@ -186,7 +186,7 @@ public function render(): \Illuminate\Contracts\View\View $editingKeywords = collect(); if ($this->editingFeedId && $this->editingChannelId) { - $editingRoute = Route::with(['feed', 'platformChannel']) + $editingRoute = Route::with(['feed', 'platformChannel.platformInstance']) ->where('feed_id', $this->editingFeedId) ->where('platform_channel_id', $this->editingChannelId) ->first(); diff --git a/resources/views/livewire/routes.blade.php b/resources/views/livewire/routes.blade.php index 364bbfa..63ef1ec 100644 --- a/resources/views/livewire/routes.blade.php +++ b/resources/views/livewire/routes.blade.php @@ -47,7 +47,7 @@ class="inline-flex items-center px-4 py-2 border border-transparent text-sm font Feed: {{ $route->feed?->name }} - Channel: {{ $route->platformChannel?->display_name ?? $route->platformChannel?->name }} + {{ $route->platformChannel?->platformInstance?->platform?->channelLabel() ?? 'Channel' }}: {{ $route->platformChannel?->display_name ?? $route->platformChannel?->name }} Created: {{ $route->created_at->format('M d, Y') }} @@ -246,7 +246,7 @@ class="px-4 py-2 text-sm font-medium text-white bg-blue-600 border border-transp Feed: {{ $editingRoute->feed?->name }}

- Channel: {{ $editingRoute->platformChannel?->display_name ?? $editingRoute->platformChannel?->name }} + {{ $editingRoute->platformChannel?->platformInstance?->platform?->channelLabel() ?? 'Channel' }}: {{ $editingRoute->platformChannel?->display_name ?? $editingRoute->platformChannel?->name }}

diff --git a/tests/Unit/Enums/PlatformEnumTest.php b/tests/Unit/Enums/PlatformEnumTest.php index 9825453..9999df2 100644 --- a/tests/Unit/Enums/PlatformEnumTest.php +++ b/tests/Unit/Enums/PlatformEnumTest.php @@ -86,4 +86,14 @@ public function test_enum_value_is_string_backed(): void { $this->assertIsString(PlatformEnum::LEMMY->value); } + + public function test_channel_label_returns_community_for_lemmy(): void + { + $this->assertEquals('Community', PlatformEnum::LEMMY->channelLabel()); + } + + public function test_channel_label_plural_returns_communities_for_lemmy(): void + { + $this->assertEquals('Communities', PlatformEnum::LEMMY->channelLabelPlural()); + } }