-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: preserve hashtags in post form (#464)
* test: add test for MfmKeyboard * refactor: split MfmKeyboard * refactor: return Note when post * feat: preserve hashtags * fix: change underline color
- Loading branch information
1 parent
04cfd12
commit ceff6f7
Showing
21 changed files
with
1,500 additions
and
502 deletions.
There are no files selected for viewing
This file contains 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 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 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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,44 @@ | ||
import 'package:collection/collection.dart'; | ||
import 'package:riverpod_annotation/riverpod_annotation.dart'; | ||
|
||
import '../model/account.dart'; | ||
import 'account_settings_notifier_provider.dart'; | ||
|
||
part 'post_form_hashtags_notifier_provider.g.dart'; | ||
|
||
@Riverpod(keepAlive: true) | ||
class PostFormHashtagsNotifier extends _$PostFormHashtagsNotifier { | ||
@override | ||
List<String> build(Account account) { | ||
return ref.watch( | ||
accountSettingsNotifierProvider(account) | ||
.select((settings) => settings.postFormHashtags), | ||
); | ||
} | ||
|
||
// ignore: use_setters_to_change_properties | ||
void updateHashtags(List<String> hashtags) { | ||
state = hashtags; | ||
} | ||
|
||
void updateFromString(String text) { | ||
updateHashtags( | ||
text | ||
.split(RegExp(r'\s')) | ||
.map((tag) => tag.trim()) | ||
.map((tag) => tag.startsWith('#') ? tag.substring(1) : tag) | ||
.where((tag) => tag.isNotEmpty) | ||
.toList(), | ||
); | ||
} | ||
|
||
Future<void> save() async { | ||
if (!state.equals( | ||
ref.read(accountSettingsNotifierProvider(account)).postFormHashtags, | ||
)) { | ||
await ref | ||
.read(accountSettingsNotifierProvider(account).notifier) | ||
.setPostFormHashtags(state); | ||
} | ||
} | ||
} |
Oops, something went wrong.