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