mirror of
https://github.com/KRTirtho/spotube.git
synced 2026-05-08 16:24:36 +00:00
feat: show alert when new client connects
This commit is contained in:
parent
2f3a2e671d
commit
0ed358eeb8
@ -317,5 +317,6 @@
|
||||
"enable_connect": "Enable Connect",
|
||||
"enable_connect_description": "Control Spotube from other devices",
|
||||
"devices": "Devices",
|
||||
"select": "Select"
|
||||
"select": "Select",
|
||||
"connect_client_alert": "You're being controlled by {client}"
|
||||
}
|
||||
@ -16,6 +16,7 @@ import 'package:spotube/components/root/spotube_navigation_bar.dart';
|
||||
import 'package:spotube/extensions/context.dart';
|
||||
import 'package:spotube/hooks/configurators/use_endless_playback.dart';
|
||||
import 'package:spotube/hooks/configurators/use_update_checker.dart';
|
||||
import 'package:spotube/provider/connect/server.dart';
|
||||
import 'package:spotube/provider/download_manager_provider.dart';
|
||||
import 'package:spotube/provider/proxy_playlist/proxy_playlist_provider.dart';
|
||||
import 'package:spotube/services/connectivity_adapter.dart';
|
||||
@ -54,8 +55,8 @@ class RootApp extends HookConsumerWidget {
|
||||
}
|
||||
});
|
||||
|
||||
final subscription = ConnectionCheckerService
|
||||
.instance.onConnectivityChanged
|
||||
final subscriptions = [
|
||||
ConnectionCheckerService.instance.onConnectivityChanged
|
||||
.listen((status) {
|
||||
if (status) {
|
||||
scaffoldMessenger.showSnackBar(
|
||||
@ -94,10 +95,35 @@ class RootApp extends HookConsumerWidget {
|
||||
),
|
||||
);
|
||||
}
|
||||
});
|
||||
}),
|
||||
connectClientStream.listen((clientOrigin) {
|
||||
scaffoldMessenger.showSnackBar(
|
||||
SnackBar(
|
||||
backgroundColor: Colors.yellow[600],
|
||||
behavior: SnackBarBehavior.floating,
|
||||
content: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Icon(
|
||||
SpotubeIcons.error,
|
||||
color: Colors.black,
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Text(
|
||||
context.l10n.connect_client_alert(clientOrigin),
|
||||
style: const TextStyle(color: Colors.black),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
})
|
||||
];
|
||||
|
||||
return () {
|
||||
for (final subscription in subscriptions) {
|
||||
subscription.cancel();
|
||||
}
|
||||
};
|
||||
}, []);
|
||||
|
||||
|
||||
@ -22,6 +22,9 @@ import 'package:web_socket_channel/web_socket_channel.dart';
|
||||
import 'package:spotube/provider/volume_provider.dart';
|
||||
|
||||
final logger = getLogger('ConnectServer');
|
||||
final _connectClientStreamController = StreamController<String>.broadcast();
|
||||
|
||||
Stream<String> get connectClientStream => _connectClientStreamController.stream;
|
||||
|
||||
final connectServerProvider = FutureProvider((ref) async {
|
||||
final enabled =
|
||||
@ -45,8 +48,14 @@ final connectServerProvider = FutureProvider((ref) async {
|
||||
|
||||
final subscriptions = <StreamSubscription>[];
|
||||
|
||||
final websocket = webSocketHandler(
|
||||
FutureOr<Response> websocket(Request req) => webSocketHandler(
|
||||
(WebSocketChannel channel, String? protocol) async {
|
||||
final context =
|
||||
(req.context["shelf.io.connection_info"] as HttpConnectionInfo?);
|
||||
final origin =
|
||||
"${context?.remoteAddress.host}:${context?.remotePort}";
|
||||
_connectClientStreamController.add(origin);
|
||||
|
||||
ref.listen(
|
||||
ProxyPlaylistNotifier.provider,
|
||||
(previous, next) {
|
||||
@ -207,7 +216,7 @@ final connectServerProvider = FutureProvider((ref) async {
|
||||
),
|
||||
]);
|
||||
},
|
||||
);
|
||||
)(req);
|
||||
|
||||
final port = Random().nextInt(17000) + 3000;
|
||||
|
||||
|
||||
@ -3,126 +3,144 @@
|
||||
"enable_connect",
|
||||
"enable_connect_description",
|
||||
"devices",
|
||||
"select"
|
||||
"select",
|
||||
"connect_client_alert"
|
||||
],
|
||||
|
||||
"bn": [
|
||||
"enable_connect",
|
||||
"enable_connect_description",
|
||||
"devices",
|
||||
"select"
|
||||
"select",
|
||||
"connect_client_alert"
|
||||
],
|
||||
|
||||
"ca": [
|
||||
"enable_connect",
|
||||
"enable_connect_description",
|
||||
"devices",
|
||||
"select"
|
||||
"select",
|
||||
"connect_client_alert"
|
||||
],
|
||||
|
||||
"de": [
|
||||
"enable_connect",
|
||||
"enable_connect_description",
|
||||
"devices",
|
||||
"select"
|
||||
"select",
|
||||
"connect_client_alert"
|
||||
],
|
||||
|
||||
"es": [
|
||||
"enable_connect",
|
||||
"enable_connect_description",
|
||||
"devices",
|
||||
"select"
|
||||
"select",
|
||||
"connect_client_alert"
|
||||
],
|
||||
|
||||
"fa": [
|
||||
"enable_connect",
|
||||
"enable_connect_description",
|
||||
"devices",
|
||||
"select"
|
||||
"select",
|
||||
"connect_client_alert"
|
||||
],
|
||||
|
||||
"fr": [
|
||||
"enable_connect",
|
||||
"enable_connect_description",
|
||||
"devices",
|
||||
"select"
|
||||
"select",
|
||||
"connect_client_alert"
|
||||
],
|
||||
|
||||
"hi": [
|
||||
"enable_connect",
|
||||
"enable_connect_description",
|
||||
"devices",
|
||||
"select"
|
||||
"select",
|
||||
"connect_client_alert"
|
||||
],
|
||||
|
||||
"it": [
|
||||
"enable_connect",
|
||||
"enable_connect_description",
|
||||
"devices",
|
||||
"select"
|
||||
"select",
|
||||
"connect_client_alert"
|
||||
],
|
||||
|
||||
"ja": [
|
||||
"enable_connect",
|
||||
"enable_connect_description",
|
||||
"devices",
|
||||
"select"
|
||||
"select",
|
||||
"connect_client_alert"
|
||||
],
|
||||
|
||||
"ko": [
|
||||
"enable_connect",
|
||||
"enable_connect_description",
|
||||
"devices",
|
||||
"select"
|
||||
"select",
|
||||
"connect_client_alert"
|
||||
],
|
||||
|
||||
"ne": [
|
||||
"enable_connect",
|
||||
"enable_connect_description",
|
||||
"devices",
|
||||
"select"
|
||||
"select",
|
||||
"connect_client_alert"
|
||||
],
|
||||
|
||||
"nl": [
|
||||
"enable_connect",
|
||||
"enable_connect_description",
|
||||
"devices",
|
||||
"select"
|
||||
"select",
|
||||
"connect_client_alert"
|
||||
],
|
||||
|
||||
"pl": [
|
||||
"enable_connect",
|
||||
"enable_connect_description",
|
||||
"devices",
|
||||
"select"
|
||||
"select",
|
||||
"connect_client_alert"
|
||||
],
|
||||
|
||||
"pt": [
|
||||
"enable_connect",
|
||||
"enable_connect_description",
|
||||
"devices",
|
||||
"select"
|
||||
"select",
|
||||
"connect_client_alert"
|
||||
],
|
||||
|
||||
"ru": [
|
||||
"enable_connect",
|
||||
"enable_connect_description",
|
||||
"devices",
|
||||
"select"
|
||||
"select",
|
||||
"connect_client_alert"
|
||||
],
|
||||
|
||||
"tr": [
|
||||
"enable_connect",
|
||||
"enable_connect_description",
|
||||
"devices",
|
||||
"select"
|
||||
"select",
|
||||
"connect_client_alert"
|
||||
],
|
||||
|
||||
"uk": [
|
||||
"enable_connect",
|
||||
"enable_connect_description",
|
||||
"devices",
|
||||
"select"
|
||||
"select",
|
||||
"connect_client_alert"
|
||||
],
|
||||
|
||||
"vi": [
|
||||
@ -131,13 +149,15 @@
|
||||
"enable_connect",
|
||||
"enable_connect_description",
|
||||
"devices",
|
||||
"select"
|
||||
"select",
|
||||
"connect_client_alert"
|
||||
],
|
||||
|
||||
"zh": [
|
||||
"enable_connect",
|
||||
"enable_connect_description",
|
||||
"devices",
|
||||
"select"
|
||||
"select",
|
||||
"connect_client_alert"
|
||||
]
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user