Skip to content

Commit

Permalink
Version 0.14.2 Beta
Browse files Browse the repository at this point in the history
  • Loading branch information
redsolver committed Jun 6, 2023
1 parent ab5a3da commit f7e3003
Show file tree
Hide file tree
Showing 15 changed files with 331 additions and 86 deletions.
1 change: 1 addition & 0 deletions lib/constants.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
const vupVersion = '0.14.2';
250 changes: 196 additions & 54 deletions lib/page/settings/portal_auth.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:clipboard/clipboard.dart';
import 'package:filesize/filesize.dart';
import 'package:s5_server/store/create.dart';
import 'package:selectable_autolink_text/selectable_autolink_text.dart';
import 'package:simple_observable/simple_observable.dart';
import 'package:url_launcher/url_launcher_string.dart';
import 'package:vup/app.dart';
import 'package:lib5/util.dart';
Expand Down Expand Up @@ -35,6 +36,14 @@ class _PortalAuthSettingsPageState extends State<PortalAuthSettingsPage> {
String? get localStoreName =>
mySky.portalAccounts['_local']?['store']?.keys.first;

final hasChanges = Observable(initialValue: false);

void updateQuota() {
quotaService.update().then((value) {
setState(() {});
});
}

@override
Widget build(BuildContext context) {
return ListView(
Expand All @@ -51,6 +60,7 @@ class _PortalAuthSettingsPageState extends State<PortalAuthSettingsPage> {

context.pop();
setState(() {});
updateQuota();
} catch (e, st) {
context.pop();
showErrorDialog(context, e, st);
Expand All @@ -72,6 +82,7 @@ class _PortalAuthSettingsPageState extends State<PortalAuthSettingsPage> {

context.pop();
setState(() {});
hasChanges.value = false;
} catch (e, st) {
context.pop();
showErrorDialog(context, e, st);
Expand Down Expand Up @@ -388,11 +399,7 @@ class _PortalAuthSettingsPageState extends State<PortalAuthSettingsPage> {
}
}
};
mySky.portalAccounts['uploadPortalOrder']
.insert(0, portalConfig.authority);

mySky.portalAccounts['enabledPortals']
.add(portalConfig.authority);
setupServiceOrder(portalConfig.authority);

dataBox.put(
'portal_${portalConfig.authority}_auth_token',
Expand All @@ -404,7 +411,7 @@ class _PortalAuthSettingsPageState extends State<PortalAuthSettingsPage> {
context.pop();
setState(() {});

quotaService.update();
updateQuota();
} catch (e, st) {
context.pop();
showErrorDialog(context, e, st);
Expand Down Expand Up @@ -495,14 +502,7 @@ class _PortalAuthSettingsPageState extends State<PortalAuthSettingsPage> {
}
};

mySky.portalAccounts['uploadPortalOrder']
.remove('_local');
mySky.portalAccounts['enabledPortals'].remove('_local');

mySky.portalAccounts['uploadPortalOrder']
.insert(0, '_local');

mySky.portalAccounts['enabledPortals'].add('_local');
setupServiceOrder('_local');

await mySky.savePortalAccounts();

Expand All @@ -519,7 +519,7 @@ class _PortalAuthSettingsPageState extends State<PortalAuthSettingsPage> {
context.pop();
setState(() {});

quotaService.update();
updateQuota();
}
} catch (e, st) {
showErrorDialog(context, e, st);
Expand Down Expand Up @@ -626,14 +626,7 @@ class _PortalAuthSettingsPageState extends State<PortalAuthSettingsPage> {
}
};

mySky.portalAccounts['uploadPortalOrder']
.remove('_local');
mySky.portalAccounts['enabledPortals'].remove('_local');

mySky.portalAccounts['uploadPortalOrder']
.insert(0, '_local');

mySky.portalAccounts['enabledPortals'].add('_local');
setupServiceOrder('_local');

await mySky.savePortalAccounts();

Expand All @@ -650,7 +643,7 @@ class _PortalAuthSettingsPageState extends State<PortalAuthSettingsPage> {
context.pop();
setState(() {});

quotaService.update();
updateQuota();
}
} catch (e, st) {
showErrorDialog(context, e, st);
Expand All @@ -664,20 +657,147 @@ class _PortalAuthSettingsPageState extends State<PortalAuthSettingsPage> {
],
),
SizedBox(
height: 16,
height: 12,
),

Text(
'Advanced',
'Uploads',
style: titleTextStyle,
),
if (s5Node.store != null)
Padding(
padding: const EdgeInsets.only(top: 6),
child: Text(
'Important: If a local store is configured, all new files and metadata are uploaded to the local store.',
SizedBox(
height: 6,
),
Text(
'Files are only uploaded to the first (1.) service, the other ones are tried if the first one fails. Metadata and thumbnails are uploaded to the services you select below.',
),
SizedBox(
height: 6,
),
Row(
children: [
SizedBox(
width: 80,
child: Text(
'Files',
style: TextStyle(fontWeight: FontWeight.bold),
),
),
),
for (final service in mySky.portalAccounts['enabledPortals'])
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: ChoiceChip(
avatar: mySky.fileUploadServiceOrder.contains(service)
? Text(
'${mySky.fileUploadServiceOrder.indexOf(service) + 1}.',
style: TextStyle(
color: Theme.of(context).colorScheme.onPrimary,
fontWeight: FontWeight.bold,
),
)
: null,
onSelected: (val) {
if (val) {
mySky.fileUploadServiceOrder.add(service);
} else {
mySky.fileUploadServiceOrder.remove(service);
}
setState(() {});
hasChanges.value = true;
},
label: Text(getServiceName(service)),
selected: mySky.fileUploadServiceOrder.contains(service),
),
),
],
),
SizedBox(height: 8),
Row(
children: [
SizedBox(
width: 80,
child: Text(
'Metadata',
style: TextStyle(fontWeight: FontWeight.bold),
),
),
for (final service in mySky.portalAccounts['enabledPortals'])
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: ChoiceChip(
onSelected: (val) {
if (val) {
mySky.metadataUploadServiceOrder.add(service);
} else {
mySky.metadataUploadServiceOrder.remove(service);
}
setState(() {});
hasChanges.value = true;
},
label: Text(getServiceName(service)),
selected: mySky.metadataUploadServiceOrder.contains(service),
),
),
],
),
SizedBox(height: 8),
Row(
children: [
SizedBox(
width: 80,
child: Text(
'Thumbnails',
style: TextStyle(fontWeight: FontWeight.bold),
),
),
for (final service in mySky.portalAccounts['enabledPortals'])
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: ChoiceChip(
onSelected: (val) {
if (val) {
mySky.thumbnailUploadServiceOrder.add(service);
} else {
mySky.thumbnailUploadServiceOrder.remove(service);
}
setState(() {});
hasChanges.value = true;
},
label: Text(getServiceName(service)),
selected: mySky.thumbnailUploadServiceOrder.contains(service),
),
),
],
),
StreamBuilder(
stream: hasChanges.values,
builder: (context, snapshot) {
if (snapshot.data == true)
return Padding(
padding: const EdgeInsets.symmetric(vertical: 16.0),
child: Text(
'You have unsaved changes. Remember to save!',
style: TextStyle(
color: Theme.of(context).primaryColor,
fontWeight: FontWeight.bold,
),
),
);
return SizedBox();
},
),
SizedBox(
height: 12,
),
/* Text(
'Pinning Automation',
style: titleTextStyle,
),
SizedBox(
height: 12,
), */
Text(
'Advanced',
style: titleTextStyle,
),
SizedBox(
height: 6,
),
Expand Down Expand Up @@ -741,7 +861,7 @@ class _PortalAuthSettingsPageState extends State<PortalAuthSettingsPage> {
),
TextField(
decoration: InputDecoration(
labelText: 'Upload Order',
labelText: 'Old Upload Order',
),
controller: TextEditingController(
text: json.encode(mySky.portalAccounts['uploadPortalOrder'])),
Expand Down Expand Up @@ -786,6 +906,26 @@ class _PortalAuthSettingsPageState extends State<PortalAuthSettingsPage> {
);
}

void setupServiceOrder(String service) {
mySky.fileUploadServiceOrder.remove(service);
mySky.fileUploadServiceOrder.insert(0, service);

mySky.metadataUploadServiceOrder.remove(service);
mySky.metadataUploadServiceOrder.add(service);
mySky.thumbnailUploadServiceOrder.remove(service);
mySky.thumbnailUploadServiceOrder.add(service);

mySky.portalAccounts['enabledPortals'].remove(service);
mySky.portalAccounts['enabledPortals'].add(service);
}

String getServiceName(String name) {
if (name == '_local') {
return localStoreName ?? '_local';
}
return name;
}

Card _buildLocalStoreCard(BuildContext context) {
final accountInfo = quotaService.accountInfos['_local'];

Expand All @@ -809,6 +949,7 @@ class _PortalAuthSettingsPageState extends State<PortalAuthSettingsPage> {
setState(() {
mySky.portalAccounts['_local'] = null;
});
hasChanges.value = true;
},
child: Text(
'Remove',
Expand Down Expand Up @@ -906,29 +1047,30 @@ class _PortalAuthSettingsPageState extends State<PortalAuthSettingsPage> {
),
if (accountInfo != null)
QuotaWidget(context: context, portal: portal),
Align(
alignment: Alignment.centerRight,
child: SizedBox(
width: 400,
child: SwitchListTile(
dense: true,
value: mySky.portalAccounts['portals'][portal]
['autoPinEnabled'] ??
false,
title: Text(
'Auto-Pin enabled',
),
subtitle: Text(
'When enabled, all data stored on one of your upload portals is replicated on this portal too',
if (false)
Align(
alignment: Alignment.centerRight,
child: SizedBox(
width: 400,
child: SwitchListTile(
dense: true,
value: mySky.portalAccounts['portals'][portal]
['autoPinEnabled'] ??
false,
title: Text(
'Auto-Pin enabled',
),
subtitle: Text(
'When enabled, all data stored on one of your upload portals is replicated on this portal too',
),
onChanged: (val) {
mySky.portalAccounts['portals'][portal]
['autoPinEnabled'] = val;
setState(() {});
},
),
onChanged: (val) {
mySky.portalAccounts['portals'][portal]['autoPinEnabled'] =
val;
setState(() {});
},
),
),
),
],
),
),
Expand Down
5 changes: 3 additions & 2 deletions lib/service/jellyfin_server/activity/listenbrainz.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'dart:convert';

import 'package:vup/constants.dart';
import 'package:vup/generic/state.dart';
import 'package:vup/service/base.dart';
import 'package:vup/service/jellyfin_server/id.dart';
Expand Down Expand Up @@ -49,8 +50,8 @@ class ListenBrainzService extends VupService {
// TODO maybe "date": "2020-01-22",
"media_player": "Jellyfin",
"submission_client": "Vup",
"media_player_version": "0.14.0",
"submission_client_version": "0.14.0",
"media_player_version": vupVersion,
"submission_client_version": vupVersion,
// TODO This should be the original "url" source for downloads
// TODO optional: cid
// "origin_url": "https://s5.cx/S5HASH.m4a",
Expand Down
Loading

0 comments on commit f7e3003

Please sign in to comment.