mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-05-07 06:56:04 +02:00
cleanup code
This commit is contained in:
+133
-129
@@ -3477,27 +3477,28 @@ CefSharp.BindObjectAsync(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var ref = API.cachedUsers.get(id);
|
var ref = API.cachedUsers.get(id);
|
||||||
|
var isVIP = API.cachedFavoritesByObjectId.has(id);
|
||||||
var ctx = {
|
var ctx = {
|
||||||
id,
|
id,
|
||||||
state: state || 'offline',
|
state: state || 'offline',
|
||||||
ref,
|
ref,
|
||||||
vip: API.cachedFavoritesByObjectId.has(id),
|
isVIP,
|
||||||
name: '',
|
name: '',
|
||||||
no: ++this.friendsNo,
|
no: ++this.friendsNo,
|
||||||
memo: this.loadMemo(id)
|
memo: this.loadMemo(id)
|
||||||
};
|
};
|
||||||
if (ref) {
|
if (ref === undefined) {
|
||||||
ctx.name = ref.name;
|
|
||||||
} else {
|
|
||||||
ref = this.friendLog[id];
|
ref = this.friendLog[id];
|
||||||
if (ref &&
|
if (ref !== undefined &&
|
||||||
ref.displayName) {
|
ref.displayName) {
|
||||||
ctx.name = ref.displayName;
|
ctx.name = ref.displayName;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
ctx.name = ref.name;
|
||||||
}
|
}
|
||||||
this.friends.set(id, ctx);
|
this.friends.set(id, ctx);
|
||||||
if (ctx.state === 'online') {
|
if (ctx.state === 'online') {
|
||||||
if (ctx.vip) {
|
if (ctx.isVIP) {
|
||||||
this.sortFriendsGroup0 = true;
|
this.sortFriendsGroup0 = true;
|
||||||
this.friendsGroup0_.push(ctx);
|
this.friendsGroup0_.push(ctx);
|
||||||
this.friendsGroupA_.unshift(ctx);
|
this.friendsGroupA_.unshift(ctx);
|
||||||
@@ -3519,10 +3520,104 @@ CefSharp.BindObjectAsync(
|
|||||||
|
|
||||||
$app.methods.deleteFriend = function (id) {
|
$app.methods.deleteFriend = function (id) {
|
||||||
var ctx = this.friends.get(id);
|
var ctx = this.friends.get(id);
|
||||||
if (ctx) {
|
if (ctx === undefined) {
|
||||||
Vue.delete(this.friend, id);
|
return;
|
||||||
|
}
|
||||||
|
this.friends.delete(id);
|
||||||
|
if (ctx.state === 'online') {
|
||||||
|
if (ctx.isVIP) {
|
||||||
|
removeFromArray(this.friendsGroup0_, ctx);
|
||||||
|
removeFromArray(this.friendsGroupA_, ctx);
|
||||||
|
} else {
|
||||||
|
removeFromArray(this.friendsGroup1_, ctx);
|
||||||
|
removeFromArray(this.friendsGroupB_, ctx);
|
||||||
|
}
|
||||||
|
} else if (ctx.state === 'active') {
|
||||||
|
removeFromArray(this.friendsGroup2_, ctx);
|
||||||
|
removeFromArray(this.friendsGroupC_, ctx);
|
||||||
|
} else {
|
||||||
|
removeFromArray(this.friendsGroup3_, ctx);
|
||||||
|
removeFromArray(this.friendsGroupD_, ctx);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
$app.methods.updateFriend = function (id, state, origin) {
|
||||||
|
var ctx = this.friends.get(id);
|
||||||
|
if (ctx === undefined) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var ref = API.cachedUsers.get(id);
|
||||||
|
var isVIP = API.cachedFavoritesByObjectId.has(id);
|
||||||
|
if (state === undefined ||
|
||||||
|
ctx.state === state) {
|
||||||
|
// this is should be: undefined -> user
|
||||||
|
if (ctx.ref !== ref) {
|
||||||
|
ctx.ref = ref;
|
||||||
|
// NOTE
|
||||||
|
// AddFriend (CurrentUser) 이후,
|
||||||
|
// 서버에서 오는 순서라고 보면 될 듯.
|
||||||
|
if (ctx.state === 'online') {
|
||||||
|
if (ctx.isVIP) {
|
||||||
|
removeFromArray(this.friendsGroupA_, ctx);
|
||||||
|
this.friendsGroupA_.push(ctx);
|
||||||
|
} else {
|
||||||
|
removeFromArray(this.friendsGroupB_, ctx);
|
||||||
|
this.friendsGroupB_.push(ctx);
|
||||||
|
}
|
||||||
|
} else if (ctx.state === 'active') {
|
||||||
|
removeFromArray(this.friendsGroupC_, ctx);
|
||||||
|
this.friendsGroupC_.push(ctx);
|
||||||
|
} else {
|
||||||
|
removeFromArray(this.friendsGroupD_, ctx);
|
||||||
|
this.friendsGroupD_.push(ctx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ctx.isVIP !== isVIP) {
|
||||||
|
ctx.isVIP = isVIP;
|
||||||
|
if (ctx.state === 'online') {
|
||||||
|
if (ctx.isVIP) {
|
||||||
|
removeFromArray(this.friendsGroup1_, ctx);
|
||||||
|
removeFromArray(this.friendsGroupB_, ctx);
|
||||||
|
this.sortFriendsGroup0 = true;
|
||||||
|
this.friendsGroup0_.push(ctx);
|
||||||
|
this.friendsGroupA_.unshift(ctx);
|
||||||
|
} else {
|
||||||
|
removeFromArray(this.friendsGroup0_, ctx);
|
||||||
|
removeFromArray(this.friendsGroupA_, ctx);
|
||||||
|
this.sortFriendsGroup1 = true;
|
||||||
|
this.friendsGroup1_.push(ctx);
|
||||||
|
this.friendsGroupB_.unshift(ctx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ref !== undefined &&
|
||||||
|
ctx.name !== ref.displayName) {
|
||||||
|
ctx.name = ref.displayName;
|
||||||
|
if (ctx.state === 'online') {
|
||||||
|
if (ctx.isVIP) {
|
||||||
|
this.sortFriendsGroup0 = true;
|
||||||
|
} else {
|
||||||
|
this.sortFriendsGroup1 = true;
|
||||||
|
}
|
||||||
|
} else if (ctx.state === 'active') {
|
||||||
|
this.sortFriendsGroup2 = true;
|
||||||
|
} else {
|
||||||
|
this.sortFriendsGroup3 = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// FIXME: 도배 가능성 있음
|
||||||
|
if (origin &&
|
||||||
|
ctx.state !== 'online' &&
|
||||||
|
ref !== undefined &&
|
||||||
|
ref.location !== '' &&
|
||||||
|
ref.location !== 'offline') {
|
||||||
|
API.getUser({
|
||||||
|
userId: id
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
if (ctx.state === 'online') {
|
if (ctx.state === 'online') {
|
||||||
if (ctx.vip) {
|
if (ctx.isVIP) {
|
||||||
removeFromArray(this.friendsGroup0_, ctx);
|
removeFromArray(this.friendsGroup0_, ctx);
|
||||||
removeFromArray(this.friendsGroupA_, ctx);
|
removeFromArray(this.friendsGroupA_, ctx);
|
||||||
} else {
|
} else {
|
||||||
@@ -3536,131 +3631,36 @@ CefSharp.BindObjectAsync(
|
|||||||
removeFromArray(this.friendsGroup3_, ctx);
|
removeFromArray(this.friendsGroup3_, ctx);
|
||||||
removeFromArray(this.friendsGroupD_, ctx);
|
removeFromArray(this.friendsGroupD_, ctx);
|
||||||
}
|
}
|
||||||
}
|
ctx.state = state;
|
||||||
};
|
ctx.ref = ref;
|
||||||
|
ctx.isVIP = isVIP;
|
||||||
$app.methods.updateFriend = function (id, state, origin) {
|
if (ref !== undefined &&
|
||||||
var ctx = this.friends.get(id);
|
ctx.name !== ref.displayName) {
|
||||||
if (ctx) {
|
ctx.name = ref.displayName;
|
||||||
var ref = API.cachedUsers.get(id);
|
}
|
||||||
var vip = API.cachedFavoritesByObjectId.has(id);
|
if (ctx.state === 'online') {
|
||||||
if (state === undefined ||
|
if (ctx.isVIP) {
|
||||||
ctx.state === state) {
|
this.sortFriendsGroup0 = true;
|
||||||
if (ctx.ref !== ref) {
|
this.friendsGroup0_.push(ctx);
|
||||||
ctx.ref = ref;
|
this.friendsGroupA_.unshift(ctx);
|
||||||
// NOTE
|
} else {
|
||||||
// AddFriend (CurrentUser) 이후,
|
this.sortFriendsGroup1 = true;
|
||||||
// 서버에서 오는 순서라고 보면 될 듯.
|
this.friendsGroup1_.push(ctx);
|
||||||
if (ctx.state === 'online') {
|
this.friendsGroupB_.unshift(ctx);
|
||||||
if (ctx.vip) {
|
|
||||||
removeFromArray(this.friendsGroupA_, ctx);
|
|
||||||
this.friendsGroupA_.push(ctx);
|
|
||||||
} else {
|
|
||||||
removeFromArray(this.friendsGroupB_, ctx);
|
|
||||||
this.friendsGroupB_.push(ctx);
|
|
||||||
}
|
|
||||||
} else if (ctx.state === 'active') {
|
|
||||||
removeFromArray(this.friendsGroupC_, ctx);
|
|
||||||
this.friendsGroupC_.push(ctx);
|
|
||||||
} else {
|
|
||||||
removeFromArray(this.friendsGroupD_, ctx);
|
|
||||||
this.friendsGroupD_.push(ctx);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (ctx.vip !== vip) {
|
|
||||||
ctx.vip = vip;
|
|
||||||
if (ctx.state === 'online') {
|
|
||||||
if (ctx.vip) {
|
|
||||||
removeFromArray(this.friendsGroup1_, ctx);
|
|
||||||
removeFromArray(this.friendsGroupB_, ctx);
|
|
||||||
this.sortFriendsGroup0 = true;
|
|
||||||
this.friendsGroup0_.push(ctx);
|
|
||||||
this.friendsGroupA_.unshift(ctx);
|
|
||||||
} else {
|
|
||||||
removeFromArray(this.friendsGroup0_, ctx);
|
|
||||||
removeFromArray(this.friendsGroupA_, ctx);
|
|
||||||
this.sortFriendsGroup1 = true;
|
|
||||||
this.friendsGroup1_.push(ctx);
|
|
||||||
this.friendsGroupB_.unshift(ctx);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (ctx.ref &&
|
|
||||||
ctx.name !== ctx.ref.displayName) {
|
|
||||||
ctx.name = ctx.ref.displayName;
|
|
||||||
if (ctx.state === 'online') {
|
|
||||||
if (ctx.vip) {
|
|
||||||
this.sortFriendsGroup0 = true;
|
|
||||||
} else {
|
|
||||||
this.sortFriendsGroup1 = true;
|
|
||||||
}
|
|
||||||
} else if (ctx.state === 'active') {
|
|
||||||
this.sortFriendsGroup2 = true;
|
|
||||||
} else {
|
|
||||||
this.sortFriendsGroup3 = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// FIXME: 도배 가능성 있음
|
|
||||||
if (origin &&
|
|
||||||
ctx.state !== 'online' &&
|
|
||||||
ctx.ref &&
|
|
||||||
ctx.ref.location !== '' &&
|
|
||||||
ctx.ref.location !== 'offline') {
|
|
||||||
API.getUser({
|
|
||||||
userId: id
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
} else if (ctx.state === 'active') {
|
||||||
|
this.sortFriendsGroup2 = true;
|
||||||
|
this.friendsGroup2_.push(ctx);
|
||||||
|
this.friendsGroupC_.unshift(ctx);
|
||||||
} else {
|
} else {
|
||||||
if (ctx.state === 'online') {
|
this.sortFriendsGroup3 = true;
|
||||||
if (ctx.vip) {
|
this.friendsGroup3_.push(ctx);
|
||||||
removeFromArray(this.friendsGroup0_, ctx);
|
this.friendsGroupD_.unshift(ctx);
|
||||||
removeFromArray(this.friendsGroupA_, ctx);
|
|
||||||
} else {
|
|
||||||
removeFromArray(this.friendsGroup1_, ctx);
|
|
||||||
removeFromArray(this.friendsGroupB_, ctx);
|
|
||||||
}
|
|
||||||
} else if (ctx.state === 'active') {
|
|
||||||
removeFromArray(this.friendsGroup2_, ctx);
|
|
||||||
removeFromArray(this.friendsGroupC_, ctx);
|
|
||||||
} else {
|
|
||||||
removeFromArray(this.friendsGroup3_, ctx);
|
|
||||||
removeFromArray(this.friendsGroupD_, ctx);
|
|
||||||
}
|
|
||||||
ctx.state = state;
|
|
||||||
if (ctx.ref !== ref) {
|
|
||||||
ctx.ref = ref;
|
|
||||||
}
|
|
||||||
if (ctx.vip !== vip) {
|
|
||||||
ctx.vip = vip;
|
|
||||||
}
|
|
||||||
if (ctx.ref &&
|
|
||||||
ctx.name !== ctx.ref.displayName) {
|
|
||||||
ctx.name = ctx.ref.displayName;
|
|
||||||
}
|
|
||||||
if (ctx.state === 'online') {
|
|
||||||
if (ctx.vip) {
|
|
||||||
this.sortFriendsGroup0 = true;
|
|
||||||
this.friendsGroup0_.push(ctx);
|
|
||||||
this.friendsGroupA_.unshift(ctx);
|
|
||||||
} else {
|
|
||||||
this.sortFriendsGroup1 = true;
|
|
||||||
this.friendsGroup1_.push(ctx);
|
|
||||||
this.friendsGroupB_.unshift(ctx);
|
|
||||||
}
|
|
||||||
} else if (ctx.state === 'active') {
|
|
||||||
this.sortFriendsGroup2 = true;
|
|
||||||
this.friendsGroup2_.push(ctx);
|
|
||||||
this.friendsGroupC_.unshift(ctx);
|
|
||||||
} else {
|
|
||||||
this.sortFriendsGroup3 = true;
|
|
||||||
this.friendsGroup3_.push(ctx);
|
|
||||||
this.friendsGroupD_.unshift(ctx);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var sortFriendByName = (a, b) => {
|
var sortFriendByName = function (a, b) {
|
||||||
var A = String(a.name).toUpperCase();
|
var A = String(a.name).toUpperCase();
|
||||||
var B = String(b.name).toUpperCase();
|
var B = String(b.name).toUpperCase();
|
||||||
if (A < B) {
|
if (A < B) {
|
||||||
@@ -3672,6 +3672,7 @@ CefSharp.BindObjectAsync(
|
|||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// VIP friends
|
||||||
$app.computed.friendsGroup0 = function () {
|
$app.computed.friendsGroup0 = function () {
|
||||||
if (this.orderFriendsGroup0) {
|
if (this.orderFriendsGroup0) {
|
||||||
return this.friendsGroupA_;
|
return this.friendsGroupA_;
|
||||||
@@ -3683,6 +3684,7 @@ CefSharp.BindObjectAsync(
|
|||||||
return this.friendsGroup0_;
|
return this.friendsGroup0_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Online friends
|
||||||
$app.computed.friendsGroup1 = function () {
|
$app.computed.friendsGroup1 = function () {
|
||||||
if (this.orderFriendsGroup1) {
|
if (this.orderFriendsGroup1) {
|
||||||
return this.friendsGroupB_;
|
return this.friendsGroupB_;
|
||||||
@@ -3694,6 +3696,7 @@ CefSharp.BindObjectAsync(
|
|||||||
return this.friendsGroup1_;
|
return this.friendsGroup1_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Active friends
|
||||||
$app.computed.friendsGroup2 = function () {
|
$app.computed.friendsGroup2 = function () {
|
||||||
if (this.orderFriendsGroup2) {
|
if (this.orderFriendsGroup2) {
|
||||||
return this.friendsGroupC_;
|
return this.friendsGroupC_;
|
||||||
@@ -3705,6 +3708,7 @@ CefSharp.BindObjectAsync(
|
|||||||
return this.friendsGroup2_;
|
return this.friendsGroup2_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Offline friends
|
||||||
$app.computed.friendsGroup3 = function () {
|
$app.computed.friendsGroup3 = function () {
|
||||||
if (this.orderFriendsGroup3) {
|
if (this.orderFriendsGroup3) {
|
||||||
return this.friendsGroupD_;
|
return this.friendsGroupD_;
|
||||||
@@ -3718,7 +3722,7 @@ CefSharp.BindObjectAsync(
|
|||||||
|
|
||||||
$app.methods.userStatusClass = function (user) {
|
$app.methods.userStatusClass = function (user) {
|
||||||
var style = {};
|
var style = {};
|
||||||
if (user) {
|
if (user !== undefined) {
|
||||||
// due to social status, check if the user isn't currentUser
|
// due to social status, check if the user isn't currentUser
|
||||||
if (user.state === 'active' &&
|
if (user.state === 'active' &&
|
||||||
user.id !== API.currentUser.id) {
|
user.id !== API.currentUser.id) {
|
||||||
|
|||||||
Reference in New Issue
Block a user