Cloud-Account-Kontingent: App liest cloud_remaining, sobald der Server es liefert
BakaAuth bekommt verbleibend/merkeVerbleibend analog zu GastZugang. YtDownloadService liest cloud_remaining bei Cloud-Zugriff (nicht bei Gast-Zugriff — Felder bleiben getrennt). UI zeigt "Noch N von 100 heute" für angemeldete Cloud-Accounts. Reine App-Seite, wirkungslos bis der Server (separates Vorhaben) cloud_remaining liefert. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012A2pmbnVNPiHdyf2GW8eLP
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
8611738124
commit
d03a4e93a0
@@ -831,6 +831,21 @@ class _YouTubeBereichState extends State<_YouTubeBereich> {
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
],
|
||||
if (auth.istAngemeldet && auth.verbleibend != null) ...[
|
||||
Row(
|
||||
children: [
|
||||
const Icon(Icons.cloud_outlined, size: 18, color: MeloTheme.text3),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: Text(
|
||||
'Noch ${auth.verbleibend} von 100 heute',
|
||||
style: const TextStyle(color: MeloTheme.text2, fontSize: 13),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
],
|
||||
if (istGastModus) ...[
|
||||
Row(
|
||||
children: [
|
||||
|
||||
@@ -159,6 +159,22 @@ class _YoutubeSearchScreenState extends State<YoutubeSearchScreen> {
|
||||
),
|
||||
],
|
||||
],
|
||||
if (auth.istAngemeldet && auth.verbleibend != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.cloud_outlined, size: 18, color: MeloTheme.text3),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: Text(
|
||||
'Noch ${auth.verbleibend} von 100 heute',
|
||||
style: const TextStyle(color: MeloTheme.text2, fontSize: 13),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (istGastModus)
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
|
||||
|
||||
@@ -47,10 +47,16 @@ class BakaAuth extends ChangeNotifier {
|
||||
|
||||
String? _token;
|
||||
String _benutzer = '';
|
||||
int? _verbleibend;
|
||||
|
||||
bool get istAngemeldet => _token != null && _token!.isNotEmpty;
|
||||
String get benutzer => _benutzer;
|
||||
|
||||
/// Zuletzt vom Server gemeldeter Kontingent-Stand (100/Tag) — nur fürs
|
||||
/// Anzeigen, die Wahrheit bleibt beim Server. `null` vor dem ersten
|
||||
/// Download in dieser Session.
|
||||
int? get verbleibend => _verbleibend;
|
||||
|
||||
/// Header für Anfragen an den Proxy. Ohne Anmeldung ohne `Authorization`.
|
||||
Map<String, String> get authHeader => {
|
||||
if (istAngemeldet) 'Authorization': 'Bearer $_token',
|
||||
@@ -111,6 +117,12 @@ class BakaAuth extends ChangeNotifier {
|
||||
await anmelden(benutzer, passwort);
|
||||
}
|
||||
|
||||
/// Übernimmt den zuletzt vom Server gemeldeten Kontingent-Stand.
|
||||
void merkeVerbleibend(int n) {
|
||||
_verbleibend = n;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<void> abmelden() async {
|
||||
_token = null;
|
||||
_benutzer = '';
|
||||
|
||||
@@ -160,6 +160,10 @@ class YtDownloadService extends ChangeNotifier {
|
||||
if (gastAktiv && gastRest != null) {
|
||||
gast!.merkeVerbleibend(gastRest);
|
||||
}
|
||||
final cloudRest = daten['cloud_remaining'] as int?;
|
||||
if (!gastAktiv && cloudRest != null) {
|
||||
auth.merkeVerbleibend(cloudRest);
|
||||
}
|
||||
|
||||
// ─── 2/2: fertige MP3 abholen und speichern ───
|
||||
_melde('Lade „$titel“ …');
|
||||
|
||||
Reference in New Issue
Block a user