Skip to content

Commit

Permalink
fix: use LineSplitter to split lines
Browse files Browse the repository at this point in the history
  • Loading branch information
poppingmoon committed Jan 27, 2025
1 parent fbdc90e commit 6465046
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
10 changes: 4 additions & 6 deletions lib/view/page/settings/mute_block_page.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:convert';

import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:go_router/go_router.dart';
Expand Down Expand Up @@ -163,9 +165,7 @@ class _MutedEmojisEditor extends HookConsumerWidget {
child: ElevatedButton.icon(
onPressed: isChanged.value
? () async {
final mutes = controller.text
.trim()
.split('\n')
final mutes = LineSplitter.split(controller.text.trim())
.map((emoji) => emoji.trim())
.where((emoji) => emoji.isNotEmpty);
await ref
Expand Down Expand Up @@ -259,9 +259,7 @@ class _InstanceMuteEditor extends HookConsumerWidget {
child: ElevatedButton.icon(
onPressed: isChanged.value
? () async {
final mutes = controller.text
.trim()
.split('\n')
final mutes = LineSplitter.split(controller.text.trim())
.map((server) => server.trim())
.where((server) => server.isNotEmpty)
.toList();
Expand Down
6 changes: 3 additions & 3 deletions lib/view/widget/muted_words_editor.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:convert';

import 'package:collection/collection.dart';
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
Expand All @@ -22,9 +24,7 @@ class MutedWordsEditor extends HookConsumerWidget {
final bool hardMute;

List<MuteWord> _parseMutes(BuildContext context, String mutes) {
return mutes
.trim()
.split('\n')
return LineSplitter.split(mutes.trim())
.map((line) => line.trim())
.mapIndexed((index, line) {
if (line.isEmpty) {
Expand Down

0 comments on commit 6465046

Please sign in to comment.