Skip to content

Commit

Permalink
🎨 优化私信速度
Browse files Browse the repository at this point in the history
  • Loading branch information
adlered committed Oct 9, 2024
1 parent 25f7bba commit 8e546c9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/main/java/org/b3log/symphony/util/Vocation.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public static boolean refresh() {
return false;
}
} catch (Exception e) {
LOGGER.log(Level.ERROR, "Failed to refresh Vocation Date. [vocationData=\"" + vocationData + "\"]", e);
LOGGER.log(Level.ERROR, "Failed to refresh Vocation Date. [vocationData=\"" + vocationData + "\"]");
return false;
}
}
Expand Down
24 changes: 13 additions & 11 deletions src/main/resources/js/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ var Chat = {
reqRecentList = $.ajax({
url: Label.servePath + '/chat/get-list?apiKey=' + apiKey,
type: 'GET',
async: false,
async: true,
success: function (result) {
if (0 === result.result) {
let data = result.data;
Expand Down Expand Up @@ -78,6 +78,7 @@ var Chat = {
var reqLoadUser = $.ajax({
url: Label.servePath + "/user/" + toUser,
type: "GET",
async: true,
success: function (result) {
if (result.code === -1) {
alert('指定的用户名不存在,请检查后重试!');
Expand Down Expand Up @@ -108,7 +109,7 @@ var Chat = {
$.ajax({
url: Label.servePath + '/chat/has-unread?apiKey=' + apiKey,
type: 'GET',
async: false,
async: true,
success: function (result) {
let count = result.result;
let list = result.data;
Expand All @@ -119,6 +120,8 @@ var Chat = {
});
} else {
// 已选定用户,获取第一页聊天信息
// 选中用户
$("#chatTo" + toUser).css("background-color", "#f1f1f1");
// 状态
$("#chatStatus").html('和 ' +
'<a href="' + Label.servePath + '/member/' + toUser + '">' + toUser + '</a> ' +
Expand Down Expand Up @@ -210,7 +213,8 @@ var Chat = {
// 用户已读
$.ajax({
url: Label.servePath + "/chat/mark-as-read?apiKey=" + apiKey + "&fromUser=" + Chat.toUser,
type: "GET"
type: "GET",
async: true
});
}
}
Expand Down Expand Up @@ -239,13 +243,13 @@ var Chat = {
$.ajax({
url: Label.servePath + "/chat/mark-as-read?apiKey=" + apiKey + "&fromUser=" + Chat.toUser,
type: "GET",
async: false
async: true
});
// 加载未读消息
var loadUnread = $.ajax({
url: Label.servePath + '/chat/has-unread?apiKey=' + apiKey,
type: 'GET',
async: false,
async: true,
success: function (result) {
let count = result.result;
let list = result.data;
Expand All @@ -254,10 +258,6 @@ var Chat = {
});
}
});
$.when(loadUnread).done(function () {
// 选中用户
$("#chatTo" + toUser).css("background-color", "#f1f1f1");
});
}
});
});
Expand All @@ -279,7 +279,7 @@ var Chat = {
$.ajax({
url: Label.servePath + "/chat/get-message?apiKey=" + apiKey + "&toUser=" + Chat.toUser + "&page=" + Chat.page + "&pageSize=20",
type: "GET",
async: false,
async: true,
success: function (result) {
try {
result.data.length;
Expand Down Expand Up @@ -448,14 +448,16 @@ var Chat = {
revoke(oId) {
$.ajax({
url: Label.servePath + "/chat/revoke?apiKey=" + apiKey + "&oId=" + oId,
type: "GET"
type: "GET",
async: true
});
},

markAllAsRead() {
$.ajax({
url: Label.servePath + "/chat/mark-all-as-read?apiKey=" + apiKey,
type: "GET",
async: true,
success: function (result) {
result.users.forEach((user) => {
$("#chatTo" + user).css("background-color", "");
Expand Down
Loading

0 comments on commit 8e546c9

Please sign in to comment.