Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 32 additions & 11 deletions lib/screens/settings_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,8 @@ class _YoutubeCookiesSection extends ConsumerStatefulWidget {
class _YoutubeCookiesSectionState
extends ConsumerState<_YoutubeCookiesSection> {
final _controller = TextEditingController();
({bool configured, bool stale, String? updatedAt})? _status;
({bool configured, bool stale, String? updatedAt, String? lastError})?
_status;
bool _loading = true;
bool _busy = false;
String? _error;
Expand Down Expand Up @@ -521,7 +522,9 @@ class _YoutubeCookiesSectionState
);
}

Widget _statusRow(({bool configured, bool stale, String? updatedAt})? s) {
Widget _statusRow(
({bool configured, bool stale, String? updatedAt, String? lastError})? s,
) {
if (s == null || !s.configured) {
return const Row(
children: [
Expand All @@ -532,17 +535,35 @@ class _YoutubeCookiesSectionState
);
}
if (s.stale) {
return const Row(
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Icon(
Icons.warning_amber_rounded,
color: NullFeedTheme.errorColor,
size: 18,
),
SizedBox(width: 8),
Expanded(
child: Text('Cookies expired — paste fresh ones to keep playing'),
const Row(
children: [
Icon(
Icons.warning_amber_rounded,
color: NullFeedTheme.errorColor,
size: 18,
),
SizedBox(width: 8),
Expanded(
child: Text(
"Cookies aren't working — re-export and paste fresh ones",
),
),
],
),
if (s.lastError != null) ...[
const SizedBox(height: 6),
Text(
s.lastError!,
style: const TextStyle(
color: NullFeedTheme.textMuted,
fontSize: 11,
fontFamily: 'monospace',
),
),
],
],
);
}
Expand Down
13 changes: 6 additions & 7 deletions lib/services/api_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -453,23 +453,22 @@ class ApiService {
});

// YouTube cookies (admin only) — enables age-restricted / members-only videos.
({bool configured, bool stale, String? updatedAt}) _parseCookieStatus(
Map<String, dynamic> data,
) => (
({bool configured, bool stale, String? updatedAt, String? lastError})
_parseCookieStatus(Map<String, dynamic> data) => (
configured: data['configured'] == true,
stale: data['stale'] == true,
updatedAt: data['updated_at'] as String?,
lastError: data['last_error'] as String?,
);

Future<({bool configured, bool stale, String? updatedAt})>
Future<({bool configured, bool stale, String? updatedAt, String? lastError})>
getYoutubeCookiesStatus() => _guard(() async {
final r = await _dio.get('$_baseUrl${AppConstants.settingsYoutubeCookies}');
return _parseCookieStatus(r.data as Map<String, dynamic>);
});

Future<({bool configured, bool stale, String? updatedAt})> saveYoutubeCookies(
String cookies,
) => _guard(() async {
Future<({bool configured, bool stale, String? updatedAt, String? lastError})>
saveYoutubeCookies(String cookies) => _guard(() async {
final r = await _dio.put(
'$_baseUrl${AppConstants.settingsYoutubeCookies}',
data: {'cookies': cookies},
Expand Down
Loading