Allow load/remove commands to take multiple entries at once

This commit is contained in:
Oystein Kristoffer Tveit 2024-12-23 13:08:17 +01:00
parent 48f03354d3
commit 8fa9c0b762
Signed by: oysteikt
GPG Key ID: 9F2F7D8250F35146
2 changed files with 8 additions and 10 deletions

View File

@ -52,11 +52,11 @@ class Command extends PlayerConnectionEvent {
// );
// }
factory Command.load(String url) {
factory Command.load(List<String> urls) {
return Command(
type: 'load',
value: {
'url': url,
'urls': urls,
},
);
}
@ -116,11 +116,11 @@ class Command extends PlayerConnectionEvent {
);
}
factory Command.playlistRemove(int position) {
factory Command.playlistRemove(List<int> positions) {
return Command(
type: 'playlist_remove',
value: {
'position': position,
'positions': positions,
},
);
}

View File

@ -107,7 +107,7 @@ class PlayerUIBody extends StatelessWidget {
color: Colors.redAccent,
onPressed: () {
BlocProvider.of<ConnectionStateBloc>(context)
.add(Command.playlistRemove(i));
.add(Command.playlistRemove([i]));
},
),
],
@ -133,7 +133,7 @@ class PlayerUIBody extends StatelessWidget {
),
onSubmitted: (value) {
BlocProvider.of<ConnectionStateBloc>(context)
.add(Command.load(value));
.add(Command.load([value]));
_textController.clear();
},
),
@ -144,7 +144,7 @@ class PlayerUIBody extends StatelessWidget {
tooltip: 'Add link to playlist',
onPressed: () {
BlocProvider.of<ConnectionStateBloc>(context)
.add(Command.load(_textController.text));
.add(Command.load([_textController.text]));
_textController.clear();
},
),
@ -159,9 +159,7 @@ class PlayerUIBody extends StatelessWidget {
return;
}
for (final link in links.split('\n')) {
blocProvider.add(Command.load(link));
}
blocProvider.add(Command.load(links.split('\n')));
},
),
],