Couple of fixes for microblogs and mentions. (#22)

This commit is contained in:
olorin99 2024-02-21 12:53:13 +10:00 committed by GitHub
parent 7277b3d6e2
commit abb128016f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 8 additions and 8 deletions

View File

@ -23,7 +23,7 @@ class APIPosts {
Future<PostListModel> list(
FeedSource source, {
int? page,
String? page,
FeedSort? sort,
List<String>? langs,
bool? usePreferredLangs,
@ -34,7 +34,7 @@ class APIPosts {
final path = source.getPostsPath()!;
final query = queryParams({
'p': page?.toString(),
'p': page,
'sort': sort?.name,
'lang': langs?.join(','),
'usePreferredLangs': (usePreferredLangs ?? false).toString(),

View File

@ -300,7 +300,7 @@ class _FeedScreenBodyState extends State<FeedScreenBody> {
),
PostType.microblog => context.read<SettingsController>().api.posts.list(
widget.source,
page: int.parse(pageKey),
page: pageKey.isEmpty ? null : pageKey,
sort: widget.sort,
usePreferredLangs: whenLoggedIn(context,
context.read<SettingsController>().useAccountLangFilter),

View File

@ -150,10 +150,10 @@ class MentionWidgetState extends State<MentionWidget> {
final modifier = widget.name[0];
final split = widget.name.substring(1).split('@');
final name = split[0];
final host = (split.length > 1 && split[1] != widget.originInstance)
final host = (split.length > 1)
? split[1]
: null;
final cacheKey = host != null ? '$name@$host' : name;
: widget.originInstance;
final cacheKey = '$name@$host';
setState(() {
_displayName = modifier + name;
@ -164,7 +164,7 @@ class MentionWidgetState extends State<MentionWidget> {
if (!userMentionCache.containsKey(cacheKey)) {
userMentionCache[cacheKey] =
await context.read<SettingsController>().api.users.getByName(
host != null ? '@$name@$host' : name,
'@$name@$host',
);
}
final user = userMentionCache[cacheKey]!;
@ -183,7 +183,7 @@ class MentionWidgetState extends State<MentionWidget> {
if (!magazineMentionCache.containsKey(cacheKey)) {
magazineMentionCache[cacheKey] =
await context.read<SettingsController>().api.magazines.getByName(
host != null ? '$name@$host' : name,
'$name@$host',
);
}
final magazine = magazineMentionCache[cacheKey]!;