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

Commit 1f2c808

Browse files
authored
Merge pull request #209 from krawieck/fix/another-user-id-fix
2 parents 6df8394 + 4a93944 commit 1f2c808

17 files changed

+97
-58
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
- Text of a post is now selectable
1616
- Tapping outside of a text input hides the keyboard
1717

18+
### Fixed
19+
20+
- Actually fixed the thing that v0.4.1 supposedly fixed
21+
1822
## v0.4.1 - 2021-04-06
1923

2024
### Fixed

lib/hooks/logged_in_action.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ VoidCallback Function(
3030
));
3131
};
3232
}
33-
return () => action(store.defaultToken!);
33+
return () => action(store.defaultUserData!.jwt);
3434
};
3535
}
3636

@@ -52,7 +52,7 @@ VoidCallback Function(
5252
));
5353
};
5454
}
55-
final token = store.defaultTokenFor(instanceHost)!;
55+
final token = store.defaultUserDataFor(instanceHost)!.jwt;
5656
return () => action(token);
5757
};
5858
}

lib/pages/communities_tab.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ class CommunitiesTab extends HookWidget {
5353
sort: SortType.active,
5454
savedOnly: false,
5555
personId:
56-
accountsStore.defaultTokenFor(instanceHost)!.payload.sub,
57-
auth: accountsStore.defaultTokenFor(instanceHost)!.raw,
56+
accountsStore.defaultUserDataFor(instanceHost)!.userId,
57+
auth: accountsStore.defaultUserDataFor(instanceHost)!.jwt.raw,
5858
))
5959
.then((e) => e.follows),
6060
)

lib/pages/community.dart

+4-3
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class CommunityPage extends HookWidget {
5555
final scrollController = useScrollController();
5656

5757
final fullCommunitySnap = useMemoFuture(() {
58-
final token = accountsStore.defaultTokenFor(instanceHost);
58+
final token = accountsStore.defaultUserDataFor(instanceHost)?.jwt;
5959

6060
if (communityId != null) {
6161
return LemmyApiV3(instanceHost).run(GetCommunity(
@@ -196,8 +196,9 @@ class CommunityPage extends HookWidget {
196196
LemmyApiV3(community.instanceHost).run(GetComments(
197197
communityId: community.community.id,
198198
auth: accountsStore
199-
.defaultTokenFor(community.instanceHost)
200-
?.raw,
199+
.defaultUserDataFor(community.instanceHost)
200+
?.jwt
201+
.raw,
201202
type: CommentListingType.community,
202203
sort: sortType,
203204
limit: batchSize,

lib/pages/create_post.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class CreatePostPage extends HookWidget {
7575
type: PostListingType.all,
7676
sort: SortType.hot,
7777
limit: 9999,
78-
auth: accStore.defaultTokenFor(selectedInstance.value)?.raw,
78+
auth: accStore.defaultUserDataFor(selectedInstance.value)?.jwt.raw,
7979
))
8080
.then(
8181
(value) {

lib/pages/full_post.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class FullPostPage extends HookWidget {
3636
final fullPostRefreshable =
3737
useRefreshable(() => LemmyApiV3(instanceHost).run(GetPost(
3838
id: id,
39-
auth: accStore.defaultTokenFor(instanceHost)?.raw,
39+
auth: accStore.defaultUserDataFor(instanceHost)?.jwt.raw,
4040
)));
4141
final loggedInAction = useLoggedInAction(instanceHost);
4242
final newComments = useState(const <CommentView>[]);

lib/pages/home_tab.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ class InfiniteHomeList extends HookWidget {
293293
page: page,
294294
limit: limit,
295295
savedOnly: false,
296-
auth: accStore.defaultTokenFor(instanceHost)?.raw,
296+
auth: accStore.defaultUserDataFor(instanceHost)?.jwt.raw,
297297
))
298298
];
299299
final instancePosts = await Future.wait(futures);
@@ -316,7 +316,7 @@ class InfiniteHomeList extends HookWidget {
316316
page: page,
317317
limit: batchSize,
318318
savedOnly: false,
319-
auth: accStore.defaultTokenFor(instanceHost)?.raw,
319+
auth: accStore.defaultUserDataFor(instanceHost)?.jwt.raw,
320320
));
321321

322322
return InfinitePostList(

lib/pages/inbox.dart

+6-6
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ class InboxPage extends HookWidget {
109109
defaultSort: SortType.new_,
110110
fetcher: (page, batchSize, sortType) =>
111111
LemmyApiV3(selectedInstance).run(GetReplies(
112-
auth: accStore.defaultTokenFor(selectedInstance)!.raw,
112+
auth: accStore.defaultUserDataFor(selectedInstance)!.jwt.raw,
113113
sort: sortType,
114114
limit: batchSize,
115115
page: page,
@@ -127,7 +127,7 @@ class InboxPage extends HookWidget {
127127
defaultSort: SortType.new_,
128128
fetcher: (page, batchSize, sortType) =>
129129
LemmyApiV3(selectedInstance).run(GetPersonMentions(
130-
auth: accStore.defaultTokenFor(selectedInstance)!.raw,
130+
auth: accStore.defaultUserDataFor(selectedInstance)!.jwt.raw,
131131
sort: sortType,
132132
limit: batchSize,
133133
page: page,
@@ -146,7 +146,7 @@ class InboxPage extends HookWidget {
146146
controller: isc,
147147
fetcher: (page, batchSize) => LemmyApiV3(selectedInstance).run(
148148
GetPrivateMessages(
149-
auth: accStore.defaultTokenFor(selectedInstance)!.raw,
149+
auth: accStore.defaultUserDataFor(selectedInstance)!.jwt.raw,
150150
limit: batchSize,
151151
page: page,
152152
unreadOnly: unreadOnly.value,
@@ -190,7 +190,7 @@ class PrivateMessageTile extends HookWidget {
190190
final toMe = useMemoized(() =>
191191
pmv.value.recipient.originInstanceHost == pmv.value.instanceHost &&
192192
pmv.value.recipient.id ==
193-
accStore.defaultTokenFor(pmv.value.instanceHost)?.payload.sub);
193+
accStore.defaultUserDataFor(pmv.value.instanceHost)?.userId);
194194

195195
final otherSide =
196196
useMemoized(() => toMe ? pmv.value.creator : pmv.value.recipient);
@@ -240,7 +240,7 @@ class PrivateMessageTile extends HookWidget {
240240
instanceHost: pmv.value.instanceHost,
241241
query: DeletePrivateMessage(
242242
privateMessageId: pmv.value.privateMessage.id,
243-
auth: accStore.defaultTokenFor(pmv.value.instanceHost)!.raw,
243+
auth: accStore.defaultUserDataFor(pmv.value.instanceHost)!.jwt.raw,
244244
deleted: !deleted.value,
245245
),
246246
onSuccess: (val) => deleted.value = val.privateMessage.deleted,
@@ -252,7 +252,7 @@ class PrivateMessageTile extends HookWidget {
252252
instanceHost: pmv.value.instanceHost,
253253
query: MarkPrivateMessageAsRead(
254254
privateMessageId: pmv.value.privateMessage.id,
255-
auth: accStore.defaultTokenFor(pmv.value.instanceHost)!.raw,
255+
auth: accStore.defaultUserDataFor(pmv.value.instanceHost)!.jwt.raw,
256256
read: !read.value,
257257
),
258258
// TODO: add notification for notifying parent list

lib/pages/instance.dart

+5-3
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,8 @@ class InstancePage extends HookWidget {
184184
limit: batchSize,
185185
page: page,
186186
savedOnly: false,
187-
auth: accStore.defaultTokenFor(instanceHost)?.raw,
187+
auth:
188+
accStore.defaultUserDataFor(instanceHost)?.jwt.raw,
188189
))),
189190
InfiniteCommentList(
190191
fetcher: (page, batchSize, sort) =>
@@ -194,7 +195,8 @@ class InstancePage extends HookWidget {
194195
limit: batchSize,
195196
page: page,
196197
savedOnly: false,
197-
auth: accStore.defaultTokenFor(instanceHost)?.raw,
198+
auth:
199+
accStore.defaultUserDataFor(instanceHost)?.jwt.raw,
198200
))),
199201
_AboutTab(site,
200202
communitiesFuture: communitiesFuture,
@@ -244,7 +246,7 @@ class _AboutTab extends HookWidget {
244246
sort: sortType,
245247
limit: batchSize,
246248
page: page,
247-
auth: accStore.defaultTokenFor(instanceHost)?.raw,
249+
auth: accStore.defaultUserDataFor(instanceHost)?.jwt.raw,
248250
),
249251
),
250252
title: 'Communities of ${site.siteView?.site.name}',

lib/pages/manage_account.dart

+6-4
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ class ManageAccountPage extends HookWidget {
2828
final accountStore = useAccountsStore();
2929

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

3434
return site.myUser!;
3535
});
@@ -98,7 +98,8 @@ class _ManageAccount extends HookWidget {
9898
final verifyPasswordFocusNode = useFocusNode();
9999
final oldPasswordFocusNode = useFocusNode();
100100

101-
final token = accountsStore.tokenFor(user.instanceHost, user.person.name)!;
101+
final token =
102+
accountsStore.userDataFor(user.instanceHost, user.person.name)!.jwt;
102103

103104
handleSubmit() async {
104105
saveDelayedLoading.start();
@@ -434,7 +435,8 @@ class _ImagePicker extends HookWidget {
434435
final upload = await PictrsApi(user.instanceHost).upload(
435436
filePath: pic.path,
436437
auth: accountsStore
437-
.tokenFor(user.instanceHost, user.person.name)!
438+
.userDataFor(user.instanceHost, user.person.name)!
439+
.jwt
438440
.raw,
439441
);
440442
pictrsDeleteToken.value = upload.files[0];

lib/pages/profile_tab.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class UserProfileTab extends HookWidget {
9191
actions: actions,
9292
),
9393
body: UserProfile(
94-
userId: accountsStore.defaultToken!.payload.sub,
94+
userId: accountsStore.defaultUserData!.userId,
9595
instanceHost: accountsStore.defaultInstanceHost!,
9696
),
9797
);

lib/pages/saved_page.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class SavedPage extends HookWidget {
4545
savedOnly: true,
4646
page: page,
4747
limit: batchSize,
48-
auth: accountStore.defaultToken!.raw,
48+
auth: accountStore.defaultUserData!.jwt.raw,
4949
),
5050
),
5151
),
@@ -58,7 +58,7 @@ class SavedPage extends HookWidget {
5858
savedOnly: true,
5959
page: page,
6060
limit: batchSize,
61-
auth: accountStore.defaultToken!.raw,
61+
auth: accountStore.defaultUserData!.jwt.raw,
6262
),
6363
),
6464
),

lib/pages/search_results.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class _SearchResultsList extends HookWidget {
8181
q: query,
8282
sort: sort,
8383
type: type,
84-
auth: accStore.defaultTokenFor(instanceHost)?.raw,
84+
auth: accStore.defaultUserDataFor(instanceHost)?.jwt.raw,
8585
page: page,
8686
limit: batchSize,
8787
));

0 commit comments

Comments
 (0)