Skip to content
This repository has been archived by the owner on Feb 4, 2023. It is now read-only.

Commit

Permalink
Merge pull request #209 from krawieck/fix/another-user-id-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
krawieck authored Apr 12, 2021
2 parents 6df8394 + 4a93944 commit 1f2c808
Show file tree
Hide file tree
Showing 17 changed files with 97 additions and 58 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
- Text of a post is now selectable
- Tapping outside of a text input hides the keyboard

### Fixed

- Actually fixed the thing that v0.4.1 supposedly fixed

## v0.4.1 - 2021-04-06

### Fixed
Expand Down
4 changes: 2 additions & 2 deletions lib/hooks/logged_in_action.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ VoidCallback Function(
));
};
}
return () => action(store.defaultToken!);
return () => action(store.defaultUserData!.jwt);
};
}

Expand All @@ -52,7 +52,7 @@ VoidCallback Function(
));
};
}
final token = store.defaultTokenFor(instanceHost)!;
final token = store.defaultUserDataFor(instanceHost)!.jwt;
return () => action(token);
};
}
4 changes: 2 additions & 2 deletions lib/pages/communities_tab.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ class CommunitiesTab extends HookWidget {
sort: SortType.active,
savedOnly: false,
personId:
accountsStore.defaultTokenFor(instanceHost)!.payload.sub,
auth: accountsStore.defaultTokenFor(instanceHost)!.raw,
accountsStore.defaultUserDataFor(instanceHost)!.userId,
auth: accountsStore.defaultUserDataFor(instanceHost)!.jwt.raw,
))
.then((e) => e.follows),
)
Expand Down
7 changes: 4 additions & 3 deletions lib/pages/community.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class CommunityPage extends HookWidget {
final scrollController = useScrollController();

final fullCommunitySnap = useMemoFuture(() {
final token = accountsStore.defaultTokenFor(instanceHost);
final token = accountsStore.defaultUserDataFor(instanceHost)?.jwt;

if (communityId != null) {
return LemmyApiV3(instanceHost).run(GetCommunity(
Expand Down Expand Up @@ -196,8 +196,9 @@ class CommunityPage extends HookWidget {
LemmyApiV3(community.instanceHost).run(GetComments(
communityId: community.community.id,
auth: accountsStore
.defaultTokenFor(community.instanceHost)
?.raw,
.defaultUserDataFor(community.instanceHost)
?.jwt
.raw,
type: CommentListingType.community,
sort: sortType,
limit: batchSize,
Expand Down
2 changes: 1 addition & 1 deletion lib/pages/create_post.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class CreatePostPage extends HookWidget {
type: PostListingType.all,
sort: SortType.hot,
limit: 9999,
auth: accStore.defaultTokenFor(selectedInstance.value)?.raw,
auth: accStore.defaultUserDataFor(selectedInstance.value)?.jwt.raw,
))
.then(
(value) {
Expand Down
2 changes: 1 addition & 1 deletion lib/pages/full_post.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class FullPostPage extends HookWidget {
final fullPostRefreshable =
useRefreshable(() => LemmyApiV3(instanceHost).run(GetPost(
id: id,
auth: accStore.defaultTokenFor(instanceHost)?.raw,
auth: accStore.defaultUserDataFor(instanceHost)?.jwt.raw,
)));
final loggedInAction = useLoggedInAction(instanceHost);
final newComments = useState(const <CommentView>[]);
Expand Down
4 changes: 2 additions & 2 deletions lib/pages/home_tab.dart
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ class InfiniteHomeList extends HookWidget {
page: page,
limit: limit,
savedOnly: false,
auth: accStore.defaultTokenFor(instanceHost)?.raw,
auth: accStore.defaultUserDataFor(instanceHost)?.jwt.raw,
))
];
final instancePosts = await Future.wait(futures);
Expand All @@ -316,7 +316,7 @@ class InfiniteHomeList extends HookWidget {
page: page,
limit: batchSize,
savedOnly: false,
auth: accStore.defaultTokenFor(instanceHost)?.raw,
auth: accStore.defaultUserDataFor(instanceHost)?.jwt.raw,
));

return InfinitePostList(
Expand Down
12 changes: 6 additions & 6 deletions lib/pages/inbox.dart
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class InboxPage extends HookWidget {
defaultSort: SortType.new_,
fetcher: (page, batchSize, sortType) =>
LemmyApiV3(selectedInstance).run(GetReplies(
auth: accStore.defaultTokenFor(selectedInstance)!.raw,
auth: accStore.defaultUserDataFor(selectedInstance)!.jwt.raw,
sort: sortType,
limit: batchSize,
page: page,
Expand All @@ -127,7 +127,7 @@ class InboxPage extends HookWidget {
defaultSort: SortType.new_,
fetcher: (page, batchSize, sortType) =>
LemmyApiV3(selectedInstance).run(GetPersonMentions(
auth: accStore.defaultTokenFor(selectedInstance)!.raw,
auth: accStore.defaultUserDataFor(selectedInstance)!.jwt.raw,
sort: sortType,
limit: batchSize,
page: page,
Expand All @@ -146,7 +146,7 @@ class InboxPage extends HookWidget {
controller: isc,
fetcher: (page, batchSize) => LemmyApiV3(selectedInstance).run(
GetPrivateMessages(
auth: accStore.defaultTokenFor(selectedInstance)!.raw,
auth: accStore.defaultUserDataFor(selectedInstance)!.jwt.raw,
limit: batchSize,
page: page,
unreadOnly: unreadOnly.value,
Expand Down Expand Up @@ -190,7 +190,7 @@ class PrivateMessageTile extends HookWidget {
final toMe = useMemoized(() =>
pmv.value.recipient.originInstanceHost == pmv.value.instanceHost &&
pmv.value.recipient.id ==
accStore.defaultTokenFor(pmv.value.instanceHost)?.payload.sub);
accStore.defaultUserDataFor(pmv.value.instanceHost)?.userId);

final otherSide =
useMemoized(() => toMe ? pmv.value.creator : pmv.value.recipient);
Expand Down Expand Up @@ -240,7 +240,7 @@ class PrivateMessageTile extends HookWidget {
instanceHost: pmv.value.instanceHost,
query: DeletePrivateMessage(
privateMessageId: pmv.value.privateMessage.id,
auth: accStore.defaultTokenFor(pmv.value.instanceHost)!.raw,
auth: accStore.defaultUserDataFor(pmv.value.instanceHost)!.jwt.raw,
deleted: !deleted.value,
),
onSuccess: (val) => deleted.value = val.privateMessage.deleted,
Expand All @@ -252,7 +252,7 @@ class PrivateMessageTile extends HookWidget {
instanceHost: pmv.value.instanceHost,
query: MarkPrivateMessageAsRead(
privateMessageId: pmv.value.privateMessage.id,
auth: accStore.defaultTokenFor(pmv.value.instanceHost)!.raw,
auth: accStore.defaultUserDataFor(pmv.value.instanceHost)!.jwt.raw,
read: !read.value,
),
// TODO: add notification for notifying parent list
Expand Down
8 changes: 5 additions & 3 deletions lib/pages/instance.dart
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ class InstancePage extends HookWidget {
limit: batchSize,
page: page,
savedOnly: false,
auth: accStore.defaultTokenFor(instanceHost)?.raw,
auth:
accStore.defaultUserDataFor(instanceHost)?.jwt.raw,
))),
InfiniteCommentList(
fetcher: (page, batchSize, sort) =>
Expand All @@ -194,7 +195,8 @@ class InstancePage extends HookWidget {
limit: batchSize,
page: page,
savedOnly: false,
auth: accStore.defaultTokenFor(instanceHost)?.raw,
auth:
accStore.defaultUserDataFor(instanceHost)?.jwt.raw,
))),
_AboutTab(site,
communitiesFuture: communitiesFuture,
Expand Down Expand Up @@ -244,7 +246,7 @@ class _AboutTab extends HookWidget {
sort: sortType,
limit: batchSize,
page: page,
auth: accStore.defaultTokenFor(instanceHost)?.raw,
auth: accStore.defaultUserDataFor(instanceHost)?.jwt.raw,
),
),
title: 'Communities of ${site.siteView?.site.name}',
Expand Down
10 changes: 6 additions & 4 deletions lib/pages/manage_account.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ class ManageAccountPage extends HookWidget {
final accountStore = useAccountsStore();

final userFuture = useMemoized(() async {
final site = await LemmyApiV3(instanceHost).run(
GetSite(auth: accountStore.tokenFor(instanceHost, username)!.raw));
final site = await LemmyApiV3(instanceHost).run(GetSite(
auth: accountStore.userDataFor(instanceHost, username)!.jwt.raw));

return site.myUser!;
});
Expand Down Expand Up @@ -98,7 +98,8 @@ class _ManageAccount extends HookWidget {
final verifyPasswordFocusNode = useFocusNode();
final oldPasswordFocusNode = useFocusNode();

final token = accountsStore.tokenFor(user.instanceHost, user.person.name)!;
final token =
accountsStore.userDataFor(user.instanceHost, user.person.name)!.jwt;

handleSubmit() async {
saveDelayedLoading.start();
Expand Down Expand Up @@ -434,7 +435,8 @@ class _ImagePicker extends HookWidget {
final upload = await PictrsApi(user.instanceHost).upload(
filePath: pic.path,
auth: accountsStore
.tokenFor(user.instanceHost, user.person.name)!
.userDataFor(user.instanceHost, user.person.name)!
.jwt
.raw,
);
pictrsDeleteToken.value = upload.files[0];
Expand Down
2 changes: 1 addition & 1 deletion lib/pages/profile_tab.dart
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class UserProfileTab extends HookWidget {
actions: actions,
),
body: UserProfile(
userId: accountsStore.defaultToken!.payload.sub,
userId: accountsStore.defaultUserData!.userId,
instanceHost: accountsStore.defaultInstanceHost!,
),
);
Expand Down
4 changes: 2 additions & 2 deletions lib/pages/saved_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class SavedPage extends HookWidget {
savedOnly: true,
page: page,
limit: batchSize,
auth: accountStore.defaultToken!.raw,
auth: accountStore.defaultUserData!.jwt.raw,
),
),
),
Expand All @@ -58,7 +58,7 @@ class SavedPage extends HookWidget {
savedOnly: true,
page: page,
limit: batchSize,
auth: accountStore.defaultToken!.raw,
auth: accountStore.defaultUserData!.jwt.raw,
),
),
),
Expand Down
2 changes: 1 addition & 1 deletion lib/pages/search_results.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class _SearchResultsList extends HookWidget {
q: query,
sort: sort,
type: type,
auth: accStore.defaultTokenFor(instanceHost)?.raw,
auth: accStore.defaultUserDataFor(instanceHost)?.jwt.raw,
page: page,
limit: batchSize,
));
Expand Down
Loading

0 comments on commit 1f2c808

Please sign in to comment.