Commit 5893efae by Sixong.Zhu

cs

parent 39bbc202
......@@ -18,14 +18,7 @@ export class EmojiService {
private static ready = false;
private static token: TokenStringGetter;
private static beforeReadyCacheAction: Function[] = [];
private url = "";
public constructor() {
this.url =
process.env.NODE_ENV === "production"
? "https://file.teammix.com"
: "";
}
private readonly url = "https://file.teammix.com";
public async getEmoji() {
if (cacheEmoji) {
......
import Axios from "axios";
import qs from "qs";
import chat from "../xim/index";
export function buildConfig(token: string, url: string) {
......@@ -9,6 +8,7 @@ export function buildConfig(token: string, url: string) {
}
return { headers: { Authorization: token } };
}
export function invokeGet<T>(url: string, token: string) {
return new Promise<T>((resolve, reject) => {
Axios.get(url, buildConfig(token, url))
......
......@@ -31,7 +31,7 @@ function uniqueMessages(
messages: NonNullable<ChatStore.STATE_CHAT_MSG_HISTORY>
) {
const arr = [...messages];
return unique(arr, function (item, all) {
return unique(arr, function(item, all) {
return all.findIndex((k) => k.id === item.id);
});
}
......@@ -52,13 +52,13 @@ async function preCacheImgs(msgs?: any[]) {
return Promise.resolve();
}
await Promise.all(
msgs.map((k) => {
msgs.filter(i => i.id > 0).map((k) => {
return new Promise((resolve: (p: void) => void) => {
if (k.type === "image") {
const msg = JSON.parse(k.msg);
const url = msg.url;
if (!isAccessibleUrl(url)) {
resolve();
return resolve();
}
if (
url &&
......@@ -315,7 +315,7 @@ export default {
state[ChatStore.STATE_CHAT_SENDING_MESSAGES] = [...current];
}
},
[ChatStore.MUTATION_SAVE_CURRENT_CHAT_INPUTING]: (function () {
[ChatStore.MUTATION_SAVE_CURRENT_CHAT_INPUTING]: (function() {
const setTimeoutId: { [key: string]: number } = {};
return (
state: ChatStoreState,
......@@ -717,7 +717,7 @@ export default {
}
commit(
ChatStore.MUTATION_SAVE_CURRENT_CHAT_MEMBERS,
unique(newChatMembers, function (item, all) {
unique(newChatMembers, function(item, all) {
return all.findIndex((k) => k.eid === item.eid);
})
);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment