Commit 5893efae by Sixong.Zhu

cs

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