Fix long relogin time caused by memos taking long time due to user cache

??? idek anymore
This commit is contained in:
Natsumi
2021-08-20 22:08:35 +12:00
parent 25051907e6
commit 38eab37f46
+8 -3
View File
@@ -5832,7 +5832,7 @@ speechSynthesis.getVoices();
database.commit(); database.commit();
}; };
$app.methods.loadMemo = async function (userId) { $app.methods.getMemo = async function (userId) {
try { try {
var row = await database.getMemo(userId); var row = await database.getMemo(userId);
return row.memo; return row.memo;
@@ -6008,6 +6008,11 @@ speechSynthesis.getVoices();
$app.updateFriend(args.ref.favoriteId); $app.updateFriend(args.ref.favoriteId);
}); });
API.$on('LOGIN', function () {
this.cachedUsers = new Map(); // fix memos loading very slowly on relogin
$app.nextFriendsRefresh = 0;
});
$app.methods.refreshFriends = function (ref, origin) { $app.methods.refreshFriends = function (ref, origin) {
var map = new Map(); var map = new Map();
for (var id of ref.friends) { for (var id of ref.friends) {
@@ -6051,7 +6056,7 @@ speechSynthesis.getVoices();
no: ++this.friendsNo, no: ++this.friendsNo,
memo: '' memo: ''
}; };
this.loadMemo(id).then((memo) => { this.getMemo(id).then((memo) => {
ctx.memo = memo; ctx.memo = memo;
}); });
if (typeof ref === 'undefined') { if (typeof ref === 'undefined') {
@@ -9394,7 +9399,7 @@ speechSynthesis.getVoices();
D.userIcon = ''; D.userIcon = '';
D.id = userId; D.id = userId;
D.treeData = []; D.treeData = [];
this.loadMemo(userId).then((memo) => { this.getMemo(userId).then((memo) => {
D.memo = memo; D.memo = memo;
var ref = this.friends.get(userId); var ref = this.friends.get(userId);
if (ref) { if (ref) {