diff --git a/lib/core/auth/auth_store.dart b/lib/core/auth/auth_store.dart index deb9072c..5b8fc210 100644 --- a/lib/core/auth/auth_store.dart +++ b/lib/core/auth/auth_store.dart @@ -78,6 +78,7 @@ abstract class _AuthBase with Store { 'redirect_uri': 'auth://', 'response_type': 'token', 'scope': 'chat:read chat:edit user:read:follows', + 'force_verify': 'true', }, ); diff --git a/lib/models/badges.dart b/lib/models/badges.dart index d7b13fb3..8662c295 100644 --- a/lib/models/badges.dart +++ b/lib/models/badges.dart @@ -13,7 +13,12 @@ class BadgeImagesTwitch { @JsonKey(name: 'image_url_4x') final String imageUrl4x; - const BadgeImagesTwitch(this.id, this.imageUrl1x, this.imageUrl2x, this.imageUrl4x); + const BadgeImagesTwitch( + this.id, + this.imageUrl1x, + this.imageUrl2x, + this.imageUrl4x, + ); factory BadgeImagesTwitch.fromJson(Map json) => _$BadgeImagesTwitchFromJson(json); } @@ -23,7 +28,10 @@ class BadgesTwitch { final String setId; final List versions; - const BadgesTwitch(this.setId, this.versions); + const BadgesTwitch( + this.setId, + this.versions, + ); factory BadgesTwitch.fromJson(Map json) => _$BadgesTwitchFromJson(json); } diff --git a/lib/screens/channel/chat/chat_store.dart b/lib/screens/channel/chat/chat_store.dart index a5964a91..191af9c3 100644 --- a/lib/screens/channel/chat/chat_store.dart +++ b/lib/screens/channel/chat/chat_store.dart @@ -64,6 +64,7 @@ abstract class _ChatStoreBase with Store { // Listen for new messages and forward them to the handler. _channel.stream.listen( (data) => _handleIRCData(data.toString()), + onError: (error) => debugPrint('Failed to connect to chat: ${error.toString()}'), onDone: () => debugPrint("Disconnected from $channelName's chat."), ); @@ -144,6 +145,7 @@ abstract class _ChatStoreBase with Store { debugPrint('Unknown command: ${parsedIRCMessage.command}'); continue; } + _deleteAndScrollToEnd(); } else if (message == 'PING :tmi.twitch.tv') { _channel.sink.add('PONG :tmi.twitch.tv'); @@ -152,28 +154,6 @@ abstract class _ChatStoreBase with Store { } } - /// Sends the given string message by the logged-in user and adds it to [messages]. - @action - void sendMessage(String message) { - // Do not send if the message is blank/empty. - if (message.isEmpty) { - return; - } - - // Send the message to the IRC chat room. - _channel.sink.add('PRIVMSG #$channelName :$message'); - - // Obtain the logged-in user's appearance in chat with USERSTATE and create the full message to render. - if (_userState != null) { - final userChatMessage = IRCMessage.fromString(_userState!); - userChatMessage.message = message; - toSend = userChatMessage; - } - - // Clear the previous input in the TextField. - textController.clear(); - } - /// If [_autoScroll] is enabled, removes messages if [messages] is too large and scrolls to the latest message. @action void _deleteAndScrollToEnd() { @@ -207,6 +187,28 @@ abstract class _ChatStoreBase with Store { }); } + /// Sends the given string message by the logged-in user and adds it to [messages]. + @action + void sendMessage(String message) { + // Do not send if the message is blank/empty. + if (message.isEmpty) { + return; + } + + // Send the message to the IRC chat room. + _channel.sink.add('PRIVMSG #$channelName :$message'); + + // Obtain the logged-in user's appearance in chat with USERSTATE and create the full message to render. + if (_userState != null) { + final userChatMessage = IRCMessage.fromString(_userState!); + userChatMessage.message = message; + toSend = userChatMessage; + } + + // Clear the previous input in the TextField. + textController.clear(); + } + /// Fetches global and channel assets (badges and emotes) and stores them in [_assetToUrl] Future getAssets() async { // Fetch the desired channel/user's information. diff --git a/lib/screens/channel/chat/chat_store.g.dart b/lib/screens/channel/chat/chat_store.g.dart index 4d7a6dd6..c67dc6eb 100644 --- a/lib/screens/channel/chat/chat_store.g.dart +++ b/lib/screens/channel/chat/chat_store.g.dart @@ -57,17 +57,6 @@ mixin _$ChatStore on _ChatStoreBase, Store { } } - @override - void sendMessage(String message) { - final _$actionInfo = _$_ChatStoreBaseActionController.startAction( - name: '_ChatStoreBase.sendMessage'); - try { - return super.sendMessage(message); - } finally { - _$_ChatStoreBaseActionController.endAction(_$actionInfo); - } - } - @override void _deleteAndScrollToEnd() { final _$actionInfo = _$_ChatStoreBaseActionController.startAction( @@ -90,6 +79,17 @@ mixin _$ChatStore on _ChatStoreBase, Store { } } + @override + void sendMessage(String message) { + final _$actionInfo = _$_ChatStoreBaseActionController.startAction( + name: '_ChatStoreBase.sendMessage'); + try { + return super.sendMessage(message); + } finally { + _$_ChatStoreBaseActionController.endAction(_$actionInfo); + } + } + @override String toString() { return ''' diff --git a/lib/screens/stream_list/streams_followed/followed_streams_store.dart b/lib/screens/stream_list/streams_followed/followed_streams_store.dart index d39f8d45..8d6fea62 100644 --- a/lib/screens/stream_list/streams_followed/followed_streams_store.dart +++ b/lib/screens/stream_list/streams_followed/followed_streams_store.dart @@ -26,7 +26,7 @@ abstract class _FollowedStreamsStoreBase with Store { bool get hasMore => _isLoading == false && _followedStreamsCurrentCursor != null; _FollowedStreamsStoreBase({required this.authStore}) { - getFollowedStreams(); + if (authStore.isLoggedIn) getFollowedStreams(); } /// Fetches the followed streams based on the current cursor.