diff --git a/html/src/app.js b/html/src/app.js
index 58212fa4..6c87eb5f 100644
--- a/html/src/app.js
+++ b/html/src/app.js
@@ -599,6 +599,14 @@ speechSynthesis.getVoices();
this.applyUserTrustLevel(ref);
this.applyUserLanguage(ref);
this.cachedUsers.set(ref.id, ref);
+
+ if (this.currentUser?.offlineFriends.includes(ref.id)) {
+ $app.addFriend(ref.id, 'offline');
+ } else if (this.currentUser?.activeFriends.includes(ref.id)) {
+ $app.addFriend(ref.id, 'active');
+ } else if (this.currentUser?.onlineFriends.includes(ref.id)) {
+ $app.addFriend(ref.id, 'online');
+ }
} else {
var props = {};
for (var prop in ref) {
@@ -4219,7 +4227,7 @@ speechSynthesis.getVoices();
API.$on('USER:CURRENT', function (args) {
// USER:CURRENT에서 처리를 함
- $app.refreshFriends(args.ref, args.origin);
+ $app.refreshFriends(args.ref, args.fromGetCurrentUser);
$app.updateOnlineFriendCoutner();
if ($app.randomUserColours) {
@@ -4252,13 +4260,9 @@ speechSynthesis.getVoices();
$app.updateFriend({ id: args.ref.favoriteId });
});
- API.$on('LOGIN', function () {
- $app.nextFriendsRefresh = 0;
- });
-
$app.methods.refreshFriendsList = async function () {
- // If we just got user less then 1 min before code call, don't call it again
- if (this.nextCurrentUserRefresh < 720) {
+ // If we just got user less then 2 min before code call, don't call it again
+ if (this.nextCurrentUserRefresh < 300) {
await API.getCurrentUser().catch((err) => {
console.error(err);
});
@@ -4269,7 +4273,10 @@ speechSynthesis.getVoices();
API.reconnectWebSocket();
};
- $app.methods.refreshFriends = function (ref, origin) {
+ $app.methods.refreshFriends = function (ref, fromGetCurrentUser) {
+ if (!this.friendLogInitStatus) {
+ return;
+ }
var map = new Map();
for (var id of ref.friends) {
map.set(id, 'offline');
@@ -4285,7 +4292,7 @@ speechSynthesis.getVoices();
}
for (var [id, state] of map) {
if (this.friends.has(id)) {
- this.updateFriend({ id, state, origin });
+ this.updateFriend({ id, state, fromGetCurrentUser });
} else {
this.addFriend(id, state);
}
@@ -4408,7 +4415,7 @@ speechSynthesis.getVoices();
$app.data.updateFriendInProgress = new Map();
$app.methods.updateFriend = function (ctx) {
- var { id, state, origin } = ctx;
+ var { id, state, fromGetCurrentUser } = ctx;
var stateInput = state;
var ctx = this.friends.get(id);
if (typeof ctx === 'undefined') {
@@ -4475,11 +4482,16 @@ speechSynthesis.getVoices();
}
// from getCurrentUser only, fetch user if offline in an instance
if (
- origin &&
+ fromGetCurrentUser &&
ctx.state !== 'online' &&
typeof ref !== 'undefined' &&
this.isRealInstance(ref.location)
) {
+ if (this.debugFriendState) {
+ console.log(
+ `Fetching offline friend in an instance ${ctx.name}`
+ );
+ }
API.getUser({
userId: id
});
@@ -5343,10 +5355,11 @@ speechSynthesis.getVoices();
} else {
await $app.initFriendLog(args.json.id);
}
+ $app.refreshFriends(args.ref, args.fromGetCurrentUser);
} catch (err) {
if (!$app.dontLogMeOut) {
$app.$message({
- message: 'Failed to load freinds list, logging out',
+ message: 'Failed to load friends list, logging out',
type: 'error'
});
this.logout();
@@ -6855,7 +6868,9 @@ speechSynthesis.getVoices();
API.getUser({
userId: id
});
- } catch {}
+ } catch (err) {
+ console.error('Fetch user on add as friend', err);
+ }
return;
}
API.getFriendStatus({
diff --git a/html/src/classes/currentUser.js b/html/src/classes/currentUser.js
index 759e3d40..95105bb3 100644
--- a/html/src/classes/currentUser.js
+++ b/html/src/classes/currentUser.js
@@ -16,7 +16,7 @@ export default class extends baseClass {
}).then((json) => {
var args = {
json,
- origin: true
+ fromGetCurrentUser: true
};
if (
json.requiresTwoFactorAuth &&
diff --git a/html/src/classes/updateLoop.js b/html/src/classes/updateLoop.js
index 3eccdc04..574ee4f3 100644
--- a/html/src/classes/updateLoop.js
+++ b/html/src/classes/updateLoop.js
@@ -6,9 +6,17 @@ export default class extends baseClass {
super(_app, _API, _t);
}
+ init() {
+ API.$on('LOGIN', function () {
+ $app.nextCurrentUserRefresh = 300;
+ $app.nextFriendsRefresh = 3600;
+ $app.nextGroupInstanceRefresh = 0;
+ });
+ }
+
_data = {
- nextCurrentUserRefresh: 0,
- nextFriendsRefresh: 0,
+ nextCurrentUserRefresh: 300,
+ nextFriendsRefresh: 3600,
nextGroupInstanceRefresh: 0,
nextAppUpdateCheck: 3600,
ipcTimeout: 0,
diff --git a/html/src/index.pug b/html/src/index.pug
index 247fad65..92a58906 100644
--- a/html/src/index.pug
+++ b/html/src/index.pug
@@ -106,6 +106,12 @@ html
include ./mixins/dialogs/groupDialog.pug
+groupDialog()
+ include ./mixins/dialogs/favoritesDialog.pug
+ +favoritesDialog()
+
+ include ./mixins/dialogs/images.pug
+ +images()
+
include ./mixins/dialogs/newInstance.pug
+newInstance()
diff --git a/html/src/mixins/dialogs/favorites.pug b/html/src/mixins/dialogs/favoritesDialog.pug
similarity index 99%
rename from html/src/mixins/dialogs/favorites.pug
rename to html/src/mixins/dialogs/favoritesDialog.pug
index 3f735902..9e31c067 100644
--- a/html/src/mixins/dialogs/favorites.pug
+++ b/html/src/mixins/dialogs/favoritesDialog.pug
@@ -1,4 +1,4 @@
-mixin favorites()
+mixin favoritesDialog()
//- dialog: favorite
el-dialog.x-dialog(:before-close="beforeDialogClose" @mousedown.native="dialogMouseDown" @mouseup.native="dialogMouseUp" ref="favoriteDialog" :visible.sync="favoriteDialog.visible" :title="$t('dialog.favorite.header')" width="300px")
div(v-if="favoriteDialog.visible" v-loading="favoriteDialog.loading")