From 7de51a5777407a2219662280a5af42545ab72d1f Mon Sep 17 00:00:00 2001 From: MjKey Date: Tue, 10 Sep 2024 11:00:08 +0300 Subject: [PATCH 01/20] Update pubspec.yaml Test Old Version Socket --- pubspec.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pubspec.yaml b/pubspec.yaml index 5134c7b..e1361c8 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -16,7 +16,7 @@ dependencies: http: ^1.2.2 logging: ^1.2.0 shared_preferences: ^2.3.1 - socket_io_client: ^2.0.3+1 + socket_io_client: ^1.0.2 web_socket_channel: ^3.0.1 cupertino_icons: ^1.0.8 shelf: ^1.4.1 @@ -44,4 +44,4 @@ flutter: - assets/styles.json - assets/pepe.gif - assets/pepe.mp3 - - lang/ \ No newline at end of file + - lang/ From 9bc232f65e38254e006f66bd277ffebb39fa3a0a Mon Sep 17 00:00:00 2001 From: MjKey Date: Tue, 10 Sep 2024 11:01:39 +0300 Subject: [PATCH 02/20] Update socket_service.dart Test Old Versions Socket --- lib/socket_service.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/socket_service.dart b/lib/socket_service.dart index d5cb2cb..bdafea5 100644 --- a/lib/socket_service.dart +++ b/lib/socket_service.dart @@ -18,6 +18,7 @@ class SocketService { _logger.info('Инициализация socket соединения'); socket = IO.io(socketUrl, { 'transports': ['websocket'], + 'forceNew': true, }); socket.on('connect', (_) { From 0898b230e68a8694a89088834e42f1d84e1085ed Mon Sep 17 00:00:00 2001 From: MjKey Date: Tue, 10 Sep 2024 11:03:09 +0300 Subject: [PATCH 03/20] Update Flutter.yml --- .github/workflows/Flutter.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/Flutter.yml b/.github/workflows/Flutter.yml index 82d93e6..140b1ad 100644 --- a/.github/workflows/Flutter.yml +++ b/.github/workflows/Flutter.yml @@ -1,7 +1,7 @@ name: Flutter Build on: push: - branches: [ "main" ] + branches: [ "3-bug-не-работает" ] paths-ignore: - '**/README.md' - '**/README-EN.md' From 5bd0a5b2dadca9504d9d341877bbf82d9a40c9fe Mon Sep 17 00:00:00 2001 From: MjKey Date: Tue, 10 Sep 2024 11:06:35 +0300 Subject: [PATCH 04/20] Update pubspec.yaml --- pubspec.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index e1361c8..4fe4a94 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -35,7 +35,6 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - flutter_lints: ^4.0.0 flutter: From 16bfa5afdad441aa52ac7c7bb879f6494501c257 Mon Sep 17 00:00:00 2001 From: MjKey Date: Tue, 10 Sep 2024 13:48:57 +0300 Subject: [PATCH 05/20] Fix Dubbling --- lib/main.dart | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/main.dart b/lib/main.dart index 3e5bcfb..f493841 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -239,6 +239,7 @@ class _MainScreenState extends State { final AudioPlayer _audioPlayer = AudioPlayer(); int _httpPort = 8080; int _wsPort = 4040; + List _processedDonations = []; final String changelog = ''' ★ Добавлен выбор стилей для таймера @@ -653,6 +654,10 @@ class _MainScreenState extends State { void _handleDonation(dynamic data) { LogManager.log(Level.INFO, 'Получено пожертвование: $data'); var donationData = json.decode(data); + if (_processedDonations.contains(donationData['id'])) { + LogManager.log(Level.WARNING, 'Донат с ID ${donationData['id']} уже обработан'); + return; + } var curr = donationData['currency'] ?? 'NOT DATA'; var show = donationData['is_shown'] ?? 'NOT DATA'; var bsys = donationData['billing_system'] ?? 'NOT DATA'; @@ -666,7 +671,7 @@ class _MainScreenState extends State { context.read().translate('Anon'); int minutesAdded = ((amountMain * _minutesPer100Rubles) / 100).round(); LogManager.log(Level.INFO, 'Добавляется: $minutesAdded минут'); - + _processedDonations.add(donationData['id']); setState(() { _timerDuration += minutesAdded * 60; _recentDonations.insert(0, DonationRecord(username, minutesAdded)); From c44fff1dfd11170eb24689a9bf5587eeac3331f9 Mon Sep 17 00:00:00 2001 From: MjKey Date: Tue, 10 Sep 2024 13:49:53 +0300 Subject: [PATCH 06/20] Update main.dart --- lib/main.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/main.dart b/lib/main.dart index f493841..109d9a9 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -239,7 +239,7 @@ class _MainScreenState extends State { final AudioPlayer _audioPlayer = AudioPlayer(); int _httpPort = 8080; int _wsPort = 4040; - List _processedDonations = []; + List _processedDonations = []; /* Может поможет */ final String changelog = ''' ★ Добавлен выбор стилей для таймера From 090c97402fd50554bd0229248e3163b4cce287f8 Mon Sep 17 00:00:00 2001 From: MjKey Date: Tue, 10 Sep 2024 13:50:42 +0300 Subject: [PATCH 07/20] Update Flutter.yml --- .github/workflows/Flutter.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/Flutter.yml b/.github/workflows/Flutter.yml index 140b1ad..aaeda20 100644 --- a/.github/workflows/Flutter.yml +++ b/.github/workflows/Flutter.yml @@ -1,7 +1,7 @@ name: Flutter Build on: push: - branches: [ "3-bug-не-работает" ] + branches: [ "Fix-Doubling-DA" ] paths-ignore: - '**/README.md' - '**/README-EN.md' From 691ee08450e8c80574d01f0a8411df4dcfe13210 Mon Sep 17 00:00:00 2001 From: MjKey Date: Tue, 10 Sep 2024 13:53:06 +0300 Subject: [PATCH 08/20] Update main.dart --- lib/main.dart | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 109d9a9..42fc41b 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -242,17 +242,8 @@ class _MainScreenState extends State { List _processedDonations = []; /* Может поможет */ final String changelog = ''' - ★ Добавлен выбор стилей для таймера - ★ Добавлен генератр стилей (CSS) для таймера - ☆ Фикс получения локального IP [issues/1] - ☆ Немножко поправлен код - - Задумки (в планах на будущее): - ✦ Добавить поддержку: - ✧ Donate.Stream - ✧ Donatty - ✧ Donatepay - ✧ StreamElements (Вряд ли) + ☆ Фикс [issues/3] + ☆ Фикс задвоение (тест) '''; String translatedChangelog = ''; From 01b81f7fa9c0cc7f20fa4be91f7953f565d43018 Mon Sep 17 00:00:00 2001 From: MjKey Date: Tue, 10 Sep 2024 13:54:04 +0300 Subject: [PATCH 09/20] Test Fix Doubling DA --- lib/main.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/main.dart b/lib/main.dart index 42fc41b..820b790 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -239,7 +239,7 @@ class _MainScreenState extends State { final AudioPlayer _audioPlayer = AudioPlayer(); int _httpPort = 8080; int _wsPort = 4040; - List _processedDonations = []; /* Может поможет */ + List _processedDonations = []; /* Может поможет (тест) */ final String changelog = ''' ☆ Фикс [issues/3] From 6f07ccce9c0301d4701133f0664fba4b1714b5dd Mon Sep 17 00:00:00 2001 From: MjKey Date: Tue, 10 Sep 2024 23:21:47 +0300 Subject: [PATCH 10/20] FIx Skip Donate --- lib/main.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 820b790..d582759 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -654,8 +654,8 @@ class _MainScreenState extends State { var bsys = donationData['billing_system'] ?? 'NOT DATA'; var bsyt = donationData['billing_system_type'] ?? 'NOT DATA'; if (donationData['currency'] == 'RUB' || - donationData['is_shown'] == 0 || - donationData['billing_system'] != 'TWITCH' || + donationData['is_shown'] == 0 && + donationData['billing_system'] != 'TWITCH' && donationData['billing_system_type'] != 'REWARDS') { double amountMain = donationData['amount_main'].toDouble(); String username = donationData['username'] ?? From 4f61b5d7208e13da27e8bdd1fc497a1f1417e219 Mon Sep 17 00:00:00 2001 From: MjKey Date: Tue, 10 Sep 2024 23:36:48 +0300 Subject: [PATCH 11/20] FIx Skip Donate --- lib/main.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index d582759..a2e8777 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -653,10 +653,10 @@ class _MainScreenState extends State { var show = donationData['is_shown'] ?? 'NOT DATA'; var bsys = donationData['billing_system'] ?? 'NOT DATA'; var bsyt = donationData['billing_system_type'] ?? 'NOT DATA'; - if (donationData['currency'] == 'RUB' || + if ((donationData['currency'] == 'RUB' && donationData['is_shown'] == 0 ) || ( donationData['is_shown'] == 0 && donationData['billing_system'] != 'TWITCH' && - donationData['billing_system_type'] != 'REWARDS') { + donationData['billing_system_type'] != 'REWARDS')) { double amountMain = donationData['amount_main'].toDouble(); String username = donationData['username'] ?? context.read().translate('Anon'); From 57c9632ab5eb1b568b8f2fe95a083f6517822f7f Mon Sep 17 00:00:00 2001 From: MjKey Date: Tue, 10 Sep 2024 23:50:06 +0300 Subject: [PATCH 12/20] FIx Skip Donate --- lib/main.dart | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index a2e8777..0a2b038 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -653,10 +653,7 @@ class _MainScreenState extends State { var show = donationData['is_shown'] ?? 'NOT DATA'; var bsys = donationData['billing_system'] ?? 'NOT DATA'; var bsyt = donationData['billing_system_type'] ?? 'NOT DATA'; - if ((donationData['currency'] == 'RUB' && donationData['is_shown'] == 0 ) || ( - donationData['is_shown'] == 0 && - donationData['billing_system'] != 'TWITCH' && - donationData['billing_system_type'] != 'REWARDS')) { + if ((donationData['currency'] == 'RUB' && donationData['is_shown'] == 0) || (donationData['is_shown'] == 0 && (donationData['billing_system'] != 'TWITCH' || donationData['billing_system_type'] != 'REWARDS'))) { double amountMain = donationData['amount_main'].toDouble(); String username = donationData['username'] ?? context.read().translate('Anon'); From 9795258cceb7044dab71ab5d12adffe09ab8676c Mon Sep 17 00:00:00 2001 From: MjKey Date: Wed, 11 Sep 2024 00:05:10 +0300 Subject: [PATCH 13/20] FIx Skip Donate --- lib/main.dart | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/main.dart b/lib/main.dart index 0a2b038..3521fac 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -653,7 +653,9 @@ class _MainScreenState extends State { var show = donationData['is_shown'] ?? 'NOT DATA'; var bsys = donationData['billing_system'] ?? 'NOT DATA'; var bsyt = donationData['billing_system_type'] ?? 'NOT DATA'; - if ((donationData['currency'] == 'RUB' && donationData['is_shown'] == 0) || (donationData['is_shown'] == 0 && (donationData['billing_system'] != 'TWITCH' || donationData['billing_system_type'] != 'REWARDS'))) { + if ((donationData['currency'] == 'RUB' and int(donationData['is_shown']) == 0) or + (int(donationData['is_shown']) == 0 and + (donationData['billing_system'] != 'TWITCH' or donationData['billing_system_type'] != 'REWARDS'))) { double amountMain = donationData['amount_main'].toDouble(); String username = donationData['username'] ?? context.read().translate('Anon'); From 9b07e30e0075d92d18acf7d909efb2b013deb203 Mon Sep 17 00:00:00 2001 From: MjKey Date: Wed, 11 Sep 2024 00:11:30 +0300 Subject: [PATCH 14/20] FIx Skip Donate --- lib/main.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 3521fac..8089f81 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -653,9 +653,9 @@ class _MainScreenState extends State { var show = donationData['is_shown'] ?? 'NOT DATA'; var bsys = donationData['billing_system'] ?? 'NOT DATA'; var bsyt = donationData['billing_system_type'] ?? 'NOT DATA'; - if ((donationData['currency'] == 'RUB' and int(donationData['is_shown']) == 0) or - (int(donationData['is_shown']) == 0 and - (donationData['billing_system'] != 'TWITCH' or donationData['billing_system_type'] != 'REWARDS'))) { + if ((donationData['currency'] == 'RUB' && int.parse(donationData['is_shown']) == 0) || + (int.parse(donationData['is_shown']) == 0 && + (donationData['billing_system'] != 'TWITCH' || donationData['billing_system_type'] != 'REWARDS'))) { double amountMain = donationData['amount_main'].toDouble(); String username = donationData['username'] ?? context.read().translate('Anon'); From e6e5be4e9d7e1dade813541169031c5a22cf70db Mon Sep 17 00:00:00 2001 From: MjKey Date: Wed, 11 Sep 2024 00:23:36 +0300 Subject: [PATCH 15/20] FIx Skip Donate --- lib/main.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/main.dart b/lib/main.dart index 8089f81..8878d24 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -655,7 +655,7 @@ class _MainScreenState extends State { var bsyt = donationData['billing_system_type'] ?? 'NOT DATA'; if ((donationData['currency'] == 'RUB' && int.parse(donationData['is_shown']) == 0) || (int.parse(donationData['is_shown']) == 0 && - (donationData['billing_system'] != 'TWITCH' || donationData['billing_system_type'] != 'REWARDS'))) { + (donationData['billing_system'] != 'TWITCH' || donationData['billing_system_type'] != 'REWARDS' || donationData['billing_system'] != 'YOUTUBE' || donationData['billing_system_type'] != 'SUBSCRIPTION'))) { double amountMain = donationData['amount_main'].toDouble(); String username = donationData['username'] ?? context.read().translate('Anon'); From 0fbda12e0ce7f46dcaac6747412193eec9251494 Mon Sep 17 00:00:00 2001 From: MjKey Date: Wed, 11 Sep 2024 00:34:30 +0300 Subject: [PATCH 16/20] FIx Skip Donate --- lib/main.dart | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 8878d24..94ddbb0 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -653,9 +653,10 @@ class _MainScreenState extends State { var show = donationData['is_shown'] ?? 'NOT DATA'; var bsys = donationData['billing_system'] ?? 'NOT DATA'; var bsyt = donationData['billing_system_type'] ?? 'NOT DATA'; - if ((donationData['currency'] == 'RUB' && int.parse(donationData['is_shown']) == 0) || - (int.parse(donationData['is_shown']) == 0 && - (donationData['billing_system'] != 'TWITCH' || donationData['billing_system_type'] != 'REWARDS' || donationData['billing_system'] != 'YOUTUBE' || donationData['billing_system_type'] != 'SUBSCRIPTION'))) { + if ((donationData['currency'] == 'RUB' && int.parse(donationData['is_shown'] ?? '1') == 0) || + (int.parse(donationData['is_shown'] ?? '1') == 0 && + (donationData['billing_system'] != 'TWITCH' && donationData['billing_system'] != 'YOUTUBE') && + (donationData['billing_system_type'] != 'REWARDS' && donationData['billing_system_type'] != 'SUBSCRIPTION'))) { double amountMain = donationData['amount_main'].toDouble(); String username = donationData['username'] ?? context.read().translate('Anon'); From 34fcf75ef9605188b27e8aa5cf773d5fe27a7044 Mon Sep 17 00:00:00 2001 From: MjKey Date: Wed, 11 Sep 2024 14:16:41 +0300 Subject: [PATCH 17/20] Sound --- lib/main.dart | 57 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 55 insertions(+), 2 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 94ddbb0..9314ea9 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -239,7 +239,11 @@ class _MainScreenState extends State { final AudioPlayer _audioPlayer = AudioPlayer(); int _httpPort = 8080; int _wsPort = 4040; - List _processedDonations = []; /* Может поможет (тест) */ + List _processedDonations = []; + List _soundFiles = []; + bool _isSoundNotificationEnabled = false; + bool _isRandomSoundEnabled = false; + AudioPlayer _audioPlayer = AudioPlayer(); final String changelog = ''' ☆ Фикс [issues/3] @@ -673,10 +677,10 @@ class _MainScreenState extends State { _topDonators = Map.fromEntries(_topDonators.entries.toList() ..sort((e1, e2) => e2.value.compareTo(e1.value))); }); - _broadcastWebSocketMessage( json.encode({'action': 'update_timer', 'duration': _timerDuration})); _saveStatistics(); + _playSound(); _broadcastWebSocketMessage(json.encode({ 'action': 'update_donations', 'recentDonations': _recentDonations @@ -815,6 +819,7 @@ class _MainScreenState extends State { _saveTimerDuration(); _broadcastWebSocketMessage( json.encode({'action': 'update_timer', 'duration': _timerDuration})); + _playSound(); } String _formatDuration(int seconds) { @@ -887,6 +892,34 @@ class _MainScreenState extends State { }, obscureText: true, ), + Divider( + color: Colors.grey, + thickness: 2, + indent: 20, + endIndent: 20, + ), + SwitchListTile( + title: Text(context.read().translate('sound_notification')), + value: _isSoundNotificationEnabled, + onChanged: (value) { + setState(() { + _isSoundNotificationEnabled = value; + }); + }, + ), + SwitchListTile( + title: Text(context.read().translate('random_sound')), + value: _isRandomSoundEnabled, + onChanged: (value) { + setState(() { + _isRandomSoundEnabled = value; + }); + }, + ), + ElevatedButton( + onPressed: _updateSoundFolder, + child: Text(context.read().translate('update_sound_folder')), + ), ], ), actions: [ @@ -1529,6 +1562,26 @@ class _MainScreenState extends State { context.read().translate('stat_clear')))); } + void _updateSoundFolder() async { + final directory = Directory('sound'); // Папка со звуками + _soundFiles = directory + .listSync() + .where((file) => file.path.endsWith('.mp3')) + .map((file) => File(file.path)) + .toList(); + LogManager.log(Level.INFO, 'Папка со звуками обновлена'); + } + + void _playSound() { + if (_isSoundNotificationEnabled && _soundFiles.isNotEmpty) { + final file = _isRandomSoundEnabled + ? (_soundFiles..shuffle()).first + : _soundFiles.first; + _audioPlayer.play(file.path, isLocal: true); + LogManager.log(Level.INFO, 'Воспроизведение звука: ${file.path}'); + } + } + @override Widget build(BuildContext context) { final themeProvider = Provider.of(context); From c3a25f0f246d3d3d6c5b9c9d969cca011e2eccf2 Mon Sep 17 00:00:00 2001 From: MjKey Date: Wed, 11 Sep 2024 14:17:35 +0300 Subject: [PATCH 18/20] Sound --- lib/main.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/main.dart b/lib/main.dart index 9314ea9..2b05a2d 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -240,7 +240,7 @@ class _MainScreenState extends State { int _httpPort = 8080; int _wsPort = 4040; List _processedDonations = []; - List _soundFiles = []; + List _soundFiles = []; // Файлы bool _isSoundNotificationEnabled = false; bool _isRandomSoundEnabled = false; AudioPlayer _audioPlayer = AudioPlayer(); From bcdf7757a33bf4afd18406f7aa584c00d5f1c846 Mon Sep 17 00:00:00 2001 From: MjKey Date: Wed, 11 Sep 2024 14:22:20 +0300 Subject: [PATCH 19/20] Update pubspec.yaml --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index 4fe4a94..1ba8eda 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -26,7 +26,7 @@ dependencies: url_launcher: ^6.3.0 qr_flutter: ^4.1.0 network_info_plus: ^6.0.0 - audioplayers: ^6.0.0 + audioplayers: ^6.1.0 google_fonts: ^6.2.1 desktop_webview_window: ^0.2.3 webview_windows: ^0.4.0 From 90c51c8f9c6434bd4862ea5eebb457b4b2000c42 Mon Sep 17 00:00:00 2001 From: MjKey Date: Wed, 11 Sep 2024 14:23:07 +0300 Subject: [PATCH 20/20] Sound --- lib/main.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/main.dart b/lib/main.dart index 2b05a2d..9f58a44 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,5 +1,4 @@ // ignore_for_file: depend_on_referenced_packages, library_private_types_in_public_api, use_build_context_synchronously, deprecated_member_use - import 'dart:io'; import 'dart:async'; import 'dart:convert';