Skip to content

Commit

Permalink
fix: analyzer warnings and format
Browse files Browse the repository at this point in the history
  • Loading branch information
SputNikPlop committed Jun 9, 2024
1 parent 967885c commit bad98ca
Show file tree
Hide file tree
Showing 13 changed files with 33 additions and 34 deletions.
15 changes: 7 additions & 8 deletions lib/src/core/services/youtube_chat.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,20 +87,19 @@ class YoutubeChat {
headers: options['headers'], body: body);
dynamic data = json.decode(response.body);


Iterable<dynamic>? messagesData = (data['continuationContents']
['liveChatContinuation']['actions'] as List?)
?.map((action) => (action['addChatItemAction']['item']
['liveChatTextMessageRenderer']));

messagesData?.forEach((message) {
if(message['message'] == null) return;
if (message['message'] == null) return;
List? messages = (message['message']['runs'] as List?)
?.map((run) => run['text'])
.where((message) => message != null)
.toList();
if(messages == null) return;
if(messages.isEmpty) return;
?.map((run) => run['text'])
.where((message) => message != null)
.toList();
if (messages == null) return;
if (messages.isEmpty) return;
ChatMessage msg = ChatMessage.fromYoutube(message, messages, videoId);
_chatStreamController.add(msg);
});
Expand All @@ -127,7 +126,7 @@ class YoutubeChat {
}

while (continuationToken != null) {
if(_chatStreamController.isClosed) return;
if (_chatStreamController.isClosed) return;
continuationToken = await fetchChatMessages(continuationToken);
await Future.delayed(const Duration(seconds: 5)); // 5-second pause
}
Expand Down
5 changes: 3 additions & 2 deletions lib/src/domain/entities/chat/chat_message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ class ChatMessage extends Equatable
);
}

factory ChatMessage.fromYoutube(dynamic messageRaw, List? messages, String videoId) {
factory ChatMessage.fromYoutube(
dynamic messageRaw, List? messages, String videoId) {
String authorName = messageRaw['authorName']['simpleText'];
String id = messageRaw['id'];
String timestamp = messageRaw['timestampUsec'];
Expand All @@ -207,7 +208,7 @@ class ChatMessage extends Equatable
rawData: '',
eventType: null,
badgesList: const [],
emotes: const {},
emotes: const {},
platform: Platform.youtube,
channelId: videoId,

Expand Down
2 changes: 1 addition & 1 deletion lib/src/presentation/controllers/home_view_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ class HomeViewController extends GetxController

Future<DataState<Settings>> getSettings() async {
DataState<Settings> settingsResult = await homeEvents.getSettings();
if (settings is DataFailed){
if (settings is DataFailed) {
return DataFailed('');
}
settings.value = settingsResult.data!;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ class RealtimeIrlViewController extends GetxController {
realtimeIrl.status.value = RtIrlStatus.updating;
timerRtIrl = Timer.periodic(const Duration(seconds: 4), (Timer t) async {
DataState<Position> p = await determinePosition();
if (p is DataSuccess && realtimeIrl.status.value == RtIrlStatus.updating) {
if (p is DataSuccess &&
realtimeIrl.status.value == RtIrlStatus.updating) {
DataState updateResult = await realtimeIrl.updatePosition(p.data!);
if(updateResult is DataFailed) {
if (updateResult is DataFailed) {
realtimeIrl.status.value = RtIrlStatus.stopped;
await stop();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ class SettingsViewController extends GetxController {
seJwtInputController.text =
homeViewController.settings.value.streamElementsSettings!.jwt ?? '';
seOverlayTokenInputController.text = homeViewController
.settings.value.streamElementsSettings!.overlayToken ?? '';
.settings.value.streamElementsSettings!.overlayToken ??
'';
rtIrlInputController.text =
homeViewController.settings.value.rtIrlPushKey ?? '';
getUsernames();
Expand Down
4 changes: 3 additions & 1 deletion lib/src/presentation/views/home_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,10 @@ class HomeView extends GetView<HomeViewController> {
),
InkWell(
onTap: () {
if (controller.selectedChatGroup.value == null)
if (controller.selectedChatGroup.value ==
null) {
return;
}
ChatViewController chatViewController =
Get.find<ChatViewController>(
tag: controller
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ class ModerationBottomSheet extends StatelessWidget {
const SizedBox(height: 15),
Visibility(
visible: message.platform == Platform.twitch,

child: Row(children: [
InkWell(
onTap: () => controller.banMessageInstruction(
Expand Down
8 changes: 6 additions & 2 deletions lib/src/presentation/widgets/chats/chat_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ class ChatView extends StatelessWidget {
if (controller == null) {
return Container();
}
bool multiplePlatform = atLeastTwoNotEmpty([controller.kickChats, controller.twitchChats, controller.youtubeChats]);
bool multiplePlatform = atLeastTwoNotEmpty([
controller.kickChats,
controller.twitchChats,
controller.youtubeChats
]);
return Obx(
() => Stack(children: [
GestureDetector(
Expand Down Expand Up @@ -203,4 +207,4 @@ bool atLeastTwoNotEmpty(List<List> lists) {
}

return false;
}
}
3 changes: 1 addition & 2 deletions lib/src/presentation/widgets/prediction.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ Widget prediction(
children: [
Text(
"No prediction running",
style: TextStyle(
),
style: TextStyle(),
),
],
);
Expand Down
4 changes: 1 addition & 3 deletions lib/src/presentation/widgets/settings/chats_joined.dart
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,7 @@ class ChatsJoined extends GetView<SettingsViewController> {
enabled: true,
);
List<Channel> channels = [...chatGroup.channels, newChan];
chatGroup = chatGroup.copyWith(
channels: channels
);
chatGroup = chatGroup.copyWith(channels: channels);
List<ChatGroup>? groups = [];
groups.addAll(controller.homeViewController.settings.value
.chatSettings?.chatGroups ??
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ Widget inAppPurchaseDialog(
),
Text(
'Events list view',
style: TextStyle(
fontSize: 13),
style: TextStyle(fontSize: 13),
)
],
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,7 @@ Widget _addDialog(context, SettingsViewController controller) {
},
decoration: const InputDecoration(
isDense: true,
contentPadding:
EdgeInsets.symmetric(horizontal: 8, vertical: 12),
contentPadding: EdgeInsets.symmetric(horizontal: 8, vertical: 12),
hintText: 'Tab title',
labelText: 'Title',
),
Expand All @@ -272,8 +271,7 @@ Widget _addDialog(context, SettingsViewController controller) {
},
decoration: const InputDecoration(
isDense: true,
contentPadding:
EdgeInsets.symmetric(horizontal: 8, vertical: 12),
contentPadding: EdgeInsets.symmetric(horizontal: 8, vertical: 12),
hintText: 'Tab url',
labelText: 'URL',
),
Expand Down Expand Up @@ -347,8 +345,7 @@ Widget _editDialog(context, SettingsViewController controller, elem) {
},
decoration: const InputDecoration(
isDense: true,
contentPadding:
EdgeInsets.symmetric(horizontal: 8, vertical: 12),
contentPadding: EdgeInsets.symmetric(horizontal: 8, vertical: 12),
hintText: 'Tab title',
labelText: 'Title',
),
Expand All @@ -372,8 +369,7 @@ Widget _editDialog(context, SettingsViewController controller, elem) {
},
decoration: const InputDecoration(
isDense: true,
contentPadding:
EdgeInsets.symmetric(horizontal: 8, vertical: 12),
contentPadding: EdgeInsets.symmetric(horizontal: 8, vertical: 12),
hintText: 'Tab url',
labelText: 'URL',
),
Expand Down
2 changes: 1 addition & 1 deletion lib/src/presentation/widgets/tabs/obs_tab_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ class ObsTabView extends GetView<ObsTabViewController> {
// ),
// ],
// ),
Divider(
const Divider(
height: 40,
),
Wrap(children: [
Expand Down

0 comments on commit bad98ca

Please sign in to comment.