diff --git a/lib/stores/chat_store.dart b/lib/stores/chat_store.dart index 73f958d1..dfea7d11 100644 --- a/lib/stores/chat_store.dart +++ b/lib/stores/chat_store.dart @@ -18,6 +18,7 @@ abstract class _ChatStoreBase with Store { List messages = []; + final Channel channelInfo; final channel = WebSocketChannel.connect(Uri.parse('wss://irc-ws.chat.twitch.tv:443')); final _assetToUrl = {}; @@ -25,25 +26,7 @@ abstract class _ChatStoreBase with Store { final scrollController = ScrollController(); - Future start(Channel channelInfo) async { - final assets = [ - await Request.getEmotesBTTVGlobal(), - await Request.getEmotesBTTVChannel(id: channelInfo.userId), - await Request.getEmotesFFZGlobal(), - await Request.getEmotesFFZChannel(id: channelInfo.userId), - await Request.getEmotesTwitchGlobal(), - await Request.getEmotesTwitchChannel(id: channelInfo.userId), - await Request.getBadgesTwitchGlobal(), - await Request.getBadgesTwitchChannel(id: channelInfo.userId), - await Request.getEmotes7TVGlobal(), - await Request.getEmotes7TVChannel(user: channelInfo.userLogin) - ]; - - for (final map in assets) { - if (map != null) { - _assetToUrl.addAll(map); - } - } + _ChatStoreBase({required this.channelInfo}) { final commands = [ 'PASS oauth:${AuthBase.token}', 'NICK justinfan888', @@ -67,6 +50,28 @@ abstract class _ChatStoreBase with Store { }); } + @action + Future getEmotes() async { + final assets = [ + await Request.getEmotesBTTVGlobal(), + await Request.getEmotesBTTVChannel(id: channelInfo.userId), + await Request.getEmotesFFZGlobal(), + await Request.getEmotesFFZChannel(id: channelInfo.userId), + await Request.getEmotesTwitchGlobal(), + await Request.getEmotesTwitchChannel(id: channelInfo.userId), + await Request.getBadgesTwitchGlobal(), + await Request.getBadgesTwitchChannel(id: channelInfo.userId), + await Request.getEmotes7TVGlobal(), + await Request.getEmotes7TVChannel(user: channelInfo.userLogin) + ]; + + for (final map in assets) { + if (map != null) { + _assetToUrl.addAll(map); + } + } + } + @action void handleWebsocketData(Object? data) { for (final message in data.toString().split('\r\n')) {