Make 3 constructors for `CommunityPage` instead of 2
instead of single default constructor using name of the community, there are now 2 where first takes community name, and second which takes the id
This commit is contained in:
parent
f00c02b631
commit
c2dedb14ac
|
@ -14,12 +14,19 @@ class CommunityPage extends HookWidget {
|
|||
final CommunityView _community;
|
||||
final String instanceUrl;
|
||||
|
||||
CommunityPage({@required String communityName, @required this.instanceUrl})
|
||||
CommunityPage.fromName(
|
||||
{@required String communityName, @required this.instanceUrl})
|
||||
: assert(communityName != null),
|
||||
assert(instanceUrl != null),
|
||||
_fullCommunityFuture =
|
||||
LemmyApi(instanceUrl).v1.getCommunity(name: communityName),
|
||||
_community = null;
|
||||
CommunityPage.fromId({@required int communityId, @required this.instanceUrl})
|
||||
: assert(communityId != null),
|
||||
assert(instanceUrl != null),
|
||||
_fullCommunityFuture =
|
||||
LemmyApi(instanceUrl).v1.getCommunity(id: communityId),
|
||||
_community = null;
|
||||
CommunityPage.fromCommunityView(this._community)
|
||||
: instanceUrl = _community.actorId.split('/')[2],
|
||||
_fullCommunityFuture = LemmyApi(_community.actorId.split('/')[2])
|
||||
|
|
Loading…
Reference in New Issue