Change create post fetching to .all

This commit is contained in:
shilangyu 2021-01-31 15:56:08 +00:00
parent e0626925ab
commit 0c7c778e85
1 changed files with 12 additions and 9 deletions

View File

@ -10,6 +10,7 @@ import '../hooks/image_picker.dart';
import '../hooks/logged_in_action.dart'; import '../hooks/logged_in_action.dart';
import '../hooks/memo_future.dart'; import '../hooks/memo_future.dart';
import '../hooks/stores.dart'; import '../hooks/stores.dart';
import '../util/extensions/api.dart';
import '../util/extensions/spaced.dart'; import '../util/extensions/spaced.dart';
import '../util/goto.dart'; import '../util/goto.dart';
import '../util/pictrs.dart'; import '../util/pictrs.dart';
@ -61,7 +62,7 @@ class CreatePostPage extends HookWidget {
final allCommunitiesSnap = useMemoFuture( final allCommunitiesSnap = useMemoFuture(
() => LemmyApiV2(selectedInstance.value) () => LemmyApiV2(selectedInstance.value)
.run(ListCommunities( .run(ListCommunities(
type: PostListingType.local, type: PostListingType.all,
sort: SortType.hot, sort: SortType.hot,
limit: 9999, limit: 9999,
auth: accStore.defaultTokenFor(selectedInstance.value).raw, auth: accStore.defaultTokenFor(selectedInstance.value).raw,
@ -134,22 +135,24 @@ class CreatePostPage extends HookWidget {
contentPadding: EdgeInsets.symmetric(vertical: 1, horizontal: 20), contentPadding: EdgeInsets.symmetric(vertical: 1, horizontal: 20),
border: OutlineInputBorder()), border: OutlineInputBorder()),
child: DropdownButtonHideUnderline( child: DropdownButtonHideUnderline(
child: DropdownButton<String>( child: DropdownButton<int>(
value: selectedCommunity.value?.community?.name, value: selectedCommunity.value?.community?.id,
hint: const Text('Community'), hint: const Text('Community'),
onChanged: (val) => selectedCommunity.value = allCommunitiesSnap.data onChanged: (communityId) => selectedCommunity.value =
.firstWhere((e) => e.community.name == val), allCommunitiesSnap.data
?.firstWhere((e) => e.community.id == communityId),
items: allCommunitiesSnap.hasData items: allCommunitiesSnap.hasData
? allCommunitiesSnap.data ? allCommunitiesSnap.data
// FIXME: use id instead of name cuz it breaks with federation
.map((e) => DropdownMenuItem( .map((e) => DropdownMenuItem(
value: e.community.name, value: e.community.id,
child: Text(e.community.name), child: Text(e.community.local
? e.community.name
: '${e.community.originInstanceHost}/${e.community.name}'),
)) ))
.toList() .toList()
: const [ : const [
DropdownMenuItem( DropdownMenuItem(
value: '', value: -1,
child: CircularProgressIndicator(), child: CircularProgressIndicator(),
) )
], ],