-
-
Notifications
You must be signed in to change notification settings - Fork 304
More progress on broadcast feature #944
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 52 commits
Commits
Show all changes
105 commits
Select commit
Hold shift + click to select a range
29eca30
add a new screen with tabs for broadcast screen, move the broadcast r…
julien4215 c1ddc11
add a dropdown menu to choose tournament in a group and round
julien4215 82063f6
use user defined locale instead of default locale
julien4215 1eaae20
add broadcast board screen
julien4215 b292db3
use adaptive circular progress indicator for broadcast list screen
julien4215 acf391f
tweak start round date on broadcast cards
julien4215 4c69c2c
make status of game nullable
julien4215 8ba6d4d
fix round date starts show on broadcast grid card
julien4215 8474de8
add a link for broadcast in nb of hours and minutes translations
julien4215 1913546
handle case where tournament description is null
julien4215 92e4da1
use Cupertino style for the broadcast screen
julien4215 af05482
add eval bar to board
julien4215 0b05ebe
add broadcast own game analysis screen with player and clock widget
julien4215 996b7e7
update comments and hide eval bar until it is ready
julien4215 da08315
fix timer by moving it in the controller
julien4215 25dcbc6
merge main into broadcast branch to fix android impeller issue
julien4215 5adb49a
rename broadcast game screeen to broadcast analysis screen
julien4215 f9ff0c4
refactor player widget and fix negative clocks
julien4215 488d520
fix text overflow and rating null case
julien4215 9ff8f79
fix broadcast analysis screen, live move are now played on the analys…
julien4215 34428a1
fix linting
julien4215 b0d1c32
fix formatting
julien4215 10fca53
add an orange border around the latest move of a broadcast game
julien4215 040eca0
show correct clocks on analysis screen board
julien4215 b012e4c
improve player widget design on broadcast analysis screen and show on…
julien4215 83ca78e
fix negative duration case
julien4215 971a430
merge main into broadcast branch to fix conflicts
julien4215 d30d5a8
revert format change to avoid conflict
julien4215 b66c827
merge upstream into broadcast
julien4215 954e2c9
revert the sync of date formatting with selected user locale
julien4215 5fde6b4
remove Intl.getCurentLocale() to complete the revert
julien4215 f1c1e95
fix deprecation warnings
julien4215 f6666b9
add a try/catch when getting broadcast preferences
julien4215 958c7d4
fix null clock on broadcast analysis screen
julien4215 7815bdb
remove isUtc since local time is used
julien4215 c3e36c0
fix test
julien4215 931efe4
merge upstream main into broadcast
julien4215 2eace64
format code
julien4215 2c9be6f
tweak scroll behavior of overview tab
julien4215 037d4f2
merge main into broadcast to fix tree view conflict
julien4215 db604ca
merge main into broadcast-feature
julien4215 1dadbc2
tweak shimmer loading
julien4215 c62052a
fix broadcast live move
julien4215 b7c1493
tweak tree rebuilding with broadcast live moves
julien4215 1bf7445
revert wip file added by mistake
julien4215 effcb5d
merge branch main into broadcast-feature to fix tree view conflict
julien4215 5de2157
rename broadcast path variable
julien4215 e450613
merge main to resolve conflicts
julien4215 854798b
follow riverpod depreciation notice
julien4215 275f40d
merge main to get broadcast translation
julien4215 7c38df7
translate broadcast tabs
julien4215 ae4bf2f
refactor broadcast analysis screen
julien4215 891b3d4
correct debug messages related to broadcast id
julien4215 afdfcaf
correct broadcast analysis option id
julien4215 3903d79
rename BroadcastAnalysisScreen to BroadcastGameAnalysisScreen
julien4215 c666bb1
use strong type for broadcast game result
julien4215 d805ac3
make the request directly rather than through a provider
julien4215 7053dc5
fix typo
julien4215 6f64494
create a new broadcast game controller that implements everything tha…
julien4215 3de1483
merge main into broadcast
julien4215 7c3bbd3
recreate the broadcast analysis screen that uses the new broadcast ga…
julien4215 05ddc9a
cleaning code
julien4215 50c2433
simplify broadcast game controller
julien4215 8ad1393
remove unused methods in broadcast state
julien4215 d785d98
remove useless broadcast game state parameters
julien4215 c8c818b
remove menu to keep only the flip board action
julien4215 0630064
remove the opening header and the opening screen in bottom bar
julien4215 dcfa4a0
remove engine depth on broadcast game screen
julien4215 99eb758
add patch for dropdown menu widget
julien4215 3232880
merge upstream to get the new clock widget
julien4215 a855430
use the new clock wigdet
julien4215 c1dd281
fix conflicts with upstream
julien4215 751cff1
fix clock test
julien4215 aaa0e67
cleaning code
julien4215 47455ae
fix local evaluation setting and tweak broadcast game controller
julien4215 7aebb8c
rename variables and fix game clock when game ends
julien4215 5182881
rename variable
julien4215 7a4dd38
more tweaks
julien4215 9462117
optimize rebuilds by listening to state in children widgets
julien4215 4a58a9c
remove rounded borders
julien4215 a85a608
really fix this time the clock not updating correctly at the end of a…
julien4215 7af00eb
use the switch syntax instead of when for AsyncValue
julien4215 ee33372
should fix some rare occurrences where clocks are not appearing on th…
julien4215 28d8323
fix format
julien4215 e03e0b4
fix new boards not being added to the round
julien4215 fd7a0c6
hopefully really really fix the clock not updating at the end of a game
julien4215 8b43cf6
still play broadcast received moves even if the game ended
julien4215 e887151
some tweaks
julien4215 943e003
fix conflicts with upstream
julien4215 3081d45
use the new AnalysisLayout widget
julien4215 825dde5
add again rounded borders
julien4215 dd822ad
fix lint error
julien4215 80ea3ca
fix last move not highlighted when opening a broadcast game
julien4215 6459547
really fix last move not highlighted
julien4215 a364245
restore the PostFrameCallback for tree view removed by mistake
julien4215 c72c703
add translations
julien4215 5b3dda4
add animation for boards thumbnails
julien4215 ba243e1
remove eval bar from this branch as it will not be part of broadcast …
julien4215 85be210
watch whole state instead of using select
julien4215 7cd047d
add dropdown_menu fixed widget
julien4215 0236f6d
merge upstream to get new search time analysis option
julien4215 be74940
fix linting
julien4215 669c7c4
fix current node taking a wrong value
julien4215 9b0aca0
fix wrong broadcast path when not on current broadcast path
julien4215 1db183e
remove old TODO and renaming
julien4215 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| import 'dart:async'; | ||
|
|
||
| import 'package:deep_pick/deep_pick.dart'; | ||
| import 'package:lichess_mobile/src/model/analysis/analysis_controller.dart'; | ||
| import 'package:lichess_mobile/src/model/broadcast/broadcast_providers.dart'; | ||
| import 'package:lichess_mobile/src/model/common/chess.dart'; | ||
| import 'package:lichess_mobile/src/model/common/id.dart'; | ||
| import 'package:lichess_mobile/src/model/common/socket.dart'; | ||
| import 'package:lichess_mobile/src/network/socket.dart'; | ||
| import 'package:lichess_mobile/src/utils/json.dart'; | ||
| import 'package:riverpod_annotation/riverpod_annotation.dart'; | ||
|
|
||
| part 'broadcast_game_controller.g.dart'; | ||
|
|
||
| @riverpod | ||
| class BroadcastGameController extends _$BroadcastGameController { | ||
| static Uri broadcastSocketUri(BroadcastRoundId broadcastRoundId) => | ||
| Uri(path: 'study/$broadcastRoundId/socket/v6'); | ||
|
|
||
| StreamSubscription<SocketEvent>? _subscription; | ||
|
|
||
| late SocketClient _socketClient; | ||
|
|
||
| @override | ||
| Future<String> build(BroadcastRoundId roundId, BroadcastGameId gameId) async { | ||
julien4215 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| _socketClient = ref | ||
| .watch(socketPoolProvider) | ||
| .open(BroadcastGameController.broadcastSocketUri(roundId)); | ||
|
|
||
| _subscription = _socketClient.stream.listen(_handleSocketEvent); | ||
|
|
||
| ref.onDispose(() { | ||
| _subscription?.cancel(); | ||
| }); | ||
|
|
||
| final pgn = await ref.watch( | ||
julien4215 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| broadcastGameProvider(roundId: roundId, gameId: gameId).future, | ||
| ); | ||
| return pgn; | ||
| } | ||
|
|
||
| void _handleSocketEvent(SocketEvent event) { | ||
| if (!state.hasValue) return; | ||
|
|
||
| switch (event.topic) { | ||
| // Sent when a node is recevied from the broadcast | ||
| case 'addNode': | ||
| _handleAddNodeEvent(event); | ||
| // Sent when a pgn tag changes | ||
| case 'setTags': | ||
| _handleSetTagsEvent(event); | ||
| } | ||
| } | ||
|
|
||
| void _handleAddNodeEvent(SocketEvent event) { | ||
| final broadcastGameId = | ||
| pick(event.data, 'p', 'chapterId').asBroadcastGameIdOrThrow(); | ||
|
|
||
| // We check if the event is for this game | ||
| if (broadcastGameId != gameId) return; | ||
|
|
||
| // The path of the last and current move of the broadcasted game | ||
| // Its value is "!" if the path is identical to one of the node that was received | ||
| final currentPath = pick(event.data, 'relayPath').asUciPathOrThrow(); | ||
|
|
||
| // We check that the event we received is for the last move of the game | ||
| if (currentPath.value != '!') return; | ||
|
|
||
| // The path for the node that was received | ||
| final path = pick(event.data, 'p', 'path').asUciPathOrThrow(); | ||
| final uciMove = pick(event.data, 'n', 'uci').asUciMoveOrThrow(); | ||
| final clock = | ||
| pick(event.data, 'n', 'clock').asDurationFromCentiSecondsOrNull(); | ||
|
|
||
| final ctrlProviderNotifier = ref.read( | ||
| analysisControllerProvider( | ||
| state.requireValue, | ||
| AnalysisState.broadcastOptions, | ||
| ).notifier, | ||
| ); | ||
|
|
||
| ctrlProviderNotifier.onBroadcastMove(path, uciMove, clock); | ||
| } | ||
|
|
||
| void _handleSetTagsEvent(SocketEvent event) { | ||
| final broadcastGameId = | ||
| pick(event.data, 'chapterId').asBroadcastGameIdOrThrow(); | ||
|
|
||
| // We check if the event is for this game | ||
| if (broadcastGameId != gameId) return; | ||
|
|
||
| final ctrlProviderNotifier = ref.read( | ||
| analysisControllerProvider( | ||
| state.requireValue, | ||
| AnalysisState.broadcastOptions, | ||
| ).notifier, | ||
| ); | ||
|
|
||
| final headers = Map.fromEntries( | ||
| pick(event.data, 'tags').asListOrThrow( | ||
| (header) => MapEntry( | ||
| header(0).asStringOrThrow(), | ||
| header(1).asStringOrThrow(), | ||
| ), | ||
| ), | ||
| ); | ||
|
|
||
| for (final entry in headers.entries) { | ||
| ctrlProviderNotifier.updatePgnHeader(entry.key, entry.value); | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.