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

Commit c32caa2

Browse files
authored
Merge pull request #198 from krawieck/hotfix/sub-id
2 parents 6e7957f + 88e1f83 commit c32caa2

File tree

6 files changed

+19
-11
lines changed

6 files changed

+19
-11
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## Unreleased
2+
3+
### Fixed
4+
5+
- Some actions would pass the wrong user id around causing infinite spinners, this is now fixed
6+
17
## v0.4.0 - 2021-04-05
28

39
### Added

lib/pages/add_instance.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class AddInstancePage extends HookWidget {
2525
final debounce = useDebounce(() async {
2626
if (prevInput == instanceController.text) return;
2727

28-
final inst = cleanUpUrl(instanceController.text);
28+
final inst = normalizeInstanceHost(instanceController.text);
2929
if (inst.isEmpty) {
3030
isSite.value = null;
3131
return;
@@ -47,7 +47,7 @@ class AddInstancePage extends HookWidget {
4747
instanceController.removeListener(debounce);
4848
};
4949
}, []);
50-
final inst = cleanUpUrl(instanceController.text);
50+
final inst = normalizeInstanceHost(instanceController.text);
5151
handleOnAdd() async {
5252
try {
5353
await accountsStore.addInstance(inst, assumeValid: true);

lib/stores/accounts_store.dart

+4-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ part 'accounts_store.g.dart';
1111
/// Store that manages all accounts
1212
@JsonSerializable()
1313
class AccountsStore extends ChangeNotifier {
14-
static const prefsKey = 'v2:AccountsStore';
14+
static const prefsKey = 'v3:AccountsStore';
1515
static final _prefs = SharedPreferences.getInstance();
1616

1717
/// Map containing JWT tokens of specific users.
@@ -206,7 +206,9 @@ class AccountsStore extends ChangeNotifier {
206206
final userData =
207207
await lemmy.run(GetSite(auth: token.raw)).then((value) => value.myUser);
208208

209-
tokens[instanceHost][userData.person.name] = token;
209+
tokens[instanceHost][userData.person.name] = token.copyWith(
210+
payload: token.payload.copyWith(sub: userData.person.id),
211+
);
210212

211213
await _assignDefaultAccounts();
212214
notifyListeners();

lib/util/cleanup_url.dart

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
/// Returns host of a url without a leading 'www.' or protocol if present also
2-
/// removes trailing '/'
3-
String cleanUpUrl(String url) {
1+
/// Returns a normalized host of a (maybe) url without a leading www.
2+
String normalizeInstanceHost(String maybeUrl) {
43
try {
5-
return urlHost(url.startsWith('https://') ? url : 'https://$url');
6-
} on FormatException catch (_) {
4+
return urlHost(
5+
maybeUrl.startsWith('https://') ? maybeUrl : 'https://$maybeUrl');
6+
} on FormatException {
77
return '';
88
}
99
}

pubspec.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ packages:
412412
name: lemmy_api_client
413413
url: "https://pub.dartlang.org"
414414
source: hosted
415-
version: "0.13.0"
415+
version: "0.14.0"
416416
logging:
417417
dependency: transitive
418418
description:

pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ dependencies:
4444
# utils
4545
timeago: ^2.0.27
4646
fuzzy: <1.0.0
47-
lemmy_api_client: ^0.13.0
47+
lemmy_api_client: ^0.14.0
4848
intl: ^0.17.0
4949
matrix4_transform: ^1.1.7
5050
json_annotation: ^4.0.1

0 commit comments

Comments
 (0)