Skip to content

Commit

Permalink
fix(providers): Use id of current cahce when save cookie
Browse files Browse the repository at this point in the history
  • Loading branch information
realth000 committed Dec 13, 2023
1 parent 27c8a13 commit 1e96a4f
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions lib/providers/storage_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,20 +79,20 @@ class Storage {
String username,
Map<String, String> cookie,
) async {
final currentCookie = _isar.databaseCookies
.where()
.usernameEqualTo(username)
.findFirst()
?.cookie ??
{};
final currentCookie = await _isar.databaseCookies
.where()
.usernameEqualTo(username)
.findFirstAsync();

final c = currentCookie?.cookie ?? {};

/// Combine two map together, do not directly use [cookie].
currentCookie.addAll(cookie);
c.addAll(cookie);
await _isar.writeAsync((isar) {
isar.databaseCookies.put(DatabaseCookie(
id: isar.databaseCookies.autoIncrement(),
id: currentCookie?.id ?? isar.databaseCookies.autoIncrement(),
username: username,
cookie: currentCookie,
cookie: c,
));
});
}
Expand Down

0 comments on commit 1e96a4f

Please sign in to comment.