mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 07:55:18 +00:00
chore: fix changing default plugin doesn't wortk
This commit is contained in:
parent
3a5ddd6214
commit
846fa679f6
@ -21,10 +21,12 @@ class MetadataInstalledPluginItem extends HookConsumerWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, ref) {
|
Widget build(BuildContext context, ref) {
|
||||||
final metadataPlugin = ref.watch(metadataPluginProvider);
|
final metadataPlugin = ref.watch(metadataPluginProvider);
|
||||||
final isAuthenticated = ref.watch(metadataPluginAuthenticatedProvider);
|
final isAuthenticatedSnapshot =
|
||||||
|
ref.watch(metadataPluginAuthenticatedProvider);
|
||||||
final pluginsNotifier = ref.watch(metadataPluginsProvider.notifier);
|
final pluginsNotifier = ref.watch(metadataPluginsProvider.notifier);
|
||||||
final requiresAuth =
|
final requiresAuth =
|
||||||
isDefault && plugin.abilities.contains(PluginAbilities.authentication);
|
isDefault && plugin.abilities.contains(PluginAbilities.authentication);
|
||||||
|
final isAuthenticated = isAuthenticatedSnapshot.asData?.value == true;
|
||||||
final updateAvailable =
|
final updateAvailable =
|
||||||
isDefault ? ref.watch(metadataPluginUpdateCheckerProvider) : null;
|
isDefault ? ref.watch(metadataPluginUpdateCheckerProvider) : null;
|
||||||
final hasUpdate = isDefault && updateAvailable?.asData?.value != null;
|
final hasUpdate = isDefault && updateAvailable?.asData?.value != null;
|
||||||
@ -70,8 +72,9 @@ class MetadataInstalledPluginItem extends HookConsumerWidget {
|
|||||||
children: [
|
children: [
|
||||||
Text(plugin.description),
|
Text(plugin.description),
|
||||||
if (repoUrl != null)
|
if (repoUrl != null)
|
||||||
Row(
|
Wrap(
|
||||||
spacing: 8,
|
spacing: 8,
|
||||||
|
runSpacing: 8,
|
||||||
children: [
|
children: [
|
||||||
if (isOfficial)
|
if (isOfficial)
|
||||||
const PrimaryBadge(
|
const PrimaryBadge(
|
||||||
@ -110,7 +113,7 @@ class MetadataInstalledPluginItem extends HookConsumerWidget {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
if (requiresAuth || hasUpdate)
|
if ((requiresAuth && !isAuthenticated) || hasUpdate)
|
||||||
Container(
|
Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: context.theme.colorScheme.secondary,
|
color: context.theme.colorScheme.secondary,
|
||||||
@ -120,7 +123,7 @@ class MetadataInstalledPluginItem extends HookConsumerWidget {
|
|||||||
child: Column(
|
child: Column(
|
||||||
spacing: 12,
|
spacing: 12,
|
||||||
children: [
|
children: [
|
||||||
if (requiresAuth)
|
if (requiresAuth && !isAuthenticated)
|
||||||
const Row(
|
const Row(
|
||||||
spacing: 8,
|
spacing: 8,
|
||||||
children: [
|
children: [
|
||||||
@ -167,9 +170,7 @@ class MetadataInstalledPluginItem extends HookConsumerWidget {
|
|||||||
? const Text("Default")
|
? const Text("Default")
|
||||||
: const Text("Set default"),
|
: const Text("Set default"),
|
||||||
),
|
),
|
||||||
if (isAuthenticated.asData?.value != true &&
|
if (isDefault && requiresAuth && !isAuthenticated)
|
||||||
requiresAuth &&
|
|
||||||
isDefault)
|
|
||||||
Button.primary(
|
Button.primary(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
await metadataPlugin.asData?.value?.auth.authenticate();
|
await metadataPlugin.asData?.value?.auth.authenticate();
|
||||||
@ -177,9 +178,7 @@ class MetadataInstalledPluginItem extends HookConsumerWidget {
|
|||||||
leading: const Icon(SpotubeIcons.login),
|
leading: const Icon(SpotubeIcons.login),
|
||||||
child: const Text("Login"),
|
child: const Text("Login"),
|
||||||
)
|
)
|
||||||
else if (isAuthenticated.asData?.value == true &&
|
else if (isDefault && requiresAuth && isAuthenticated)
|
||||||
requiresAuth &&
|
|
||||||
isDefault)
|
|
||||||
Button.destructive(
|
Button.destructive(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
await metadataPlugin.asData?.value?.auth.logout();
|
await metadataPlugin.asData?.value?.auth.logout();
|
||||||
|
@ -76,7 +76,7 @@ class SettingsMetadataProviderPage extends HookConsumerWidget {
|
|||||||
validator: FormBuilderValidators.url(
|
validator: FormBuilderValidators.url(
|
||||||
protocols: ["http", "https"]),
|
protocols: ["http", "https"]),
|
||||||
placeholder: const Text(
|
placeholder: const Text(
|
||||||
"Add GitHub/Codeberg URL to plugin repository "
|
"Paste download url or GitHub/Codeberg repo url"
|
||||||
"or direct link to .smplug file",
|
"or direct link to .smplug file",
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -198,6 +198,7 @@ class SettingsMetadataProviderPage extends HookConsumerWidget {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
const SliverGap(20),
|
||||||
SliverCrossAxisConstrained(
|
SliverCrossAxisConstrained(
|
||||||
maxCrossAxisExtent: 720,
|
maxCrossAxisExtent: 720,
|
||||||
child: SliverFillRemaining(
|
child: SliverFillRemaining(
|
||||||
|
@ -370,6 +370,10 @@ class MetadataPluginNotifier extends AsyncNotifier<MetadataPluginState> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> setDefaultPlugin(PluginConfiguration plugin) async {
|
Future<void> setDefaultPlugin(PluginConfiguration plugin) async {
|
||||||
|
await database.metadataPluginsTable
|
||||||
|
.update()
|
||||||
|
.write(const MetadataPluginsTableCompanion(selected: Value(false)));
|
||||||
|
|
||||||
await (database.metadataPluginsTable.update()
|
await (database.metadataPluginsTable.update()
|
||||||
..where((tbl) => tbl.name.equals(plugin.name)))
|
..where((tbl) => tbl.name.equals(plugin.name)))
|
||||||
.write(
|
.write(
|
||||||
|
Loading…
Reference in New Issue
Block a user