Commit d1c3f11e by Sixong.Zhu

Merge branch 'master' into pre

parents fc3973b2 613baad6
...@@ -32,7 +32,7 @@ function uniqueMessages( ...@@ -32,7 +32,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);
}); });
} }
...@@ -362,7 +362,7 @@ export default { ...@@ -362,7 +362,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,
...@@ -469,7 +469,7 @@ export default { ...@@ -469,7 +469,7 @@ export default {
.sort(); .sort();
const last = ts[ts.length - 1]; const last = ts[ts.length - 1];
const execute = () => const execute = () =>
new Promise<ChatType[]>((resolve) => { new Promise<ChatType[]>((resolve, reject) => {
Chat.onReady(() => { Chat.onReady(() => {
xim.fetchChatListAfter(last)!.then((r) => { xim.fetchChatListAfter(last)!.then((r) => {
const list = filterActiveChats( const list = filterActiveChats(
...@@ -483,7 +483,7 @@ export default { ...@@ -483,7 +483,7 @@ export default {
); );
} }
resolve(buildUnreadMessage(cache)); resolve(buildUnreadMessage(cache));
}); }).catch(reject);
}); });
}).finally(() => (loadingChatList = false)); }).finally(() => (loadingChatList = false));
...@@ -491,7 +491,7 @@ export default { ...@@ -491,7 +491,7 @@ export default {
} }
const execute = () => const execute = () =>
new Promise<ChatType[]>((resolve) => { new Promise<ChatType[]>((resolve, reject) => {
Chat.onReady(() => { Chat.onReady(() => {
xim.fetchChatList().then((data) => { xim.fetchChatList().then((data) => {
if (!data) { if (!data) {
...@@ -506,7 +506,7 @@ export default { ...@@ -506,7 +506,7 @@ export default {
dbController.saveChatList(items); dbController.saveChatList(items);
commit(ChatStore.MUTATION_SAVE_CHAT_LIST, items); commit(ChatStore.MUTATION_SAVE_CHAT_LIST, items);
resolve(buildUnreadMessage(items)); resolve(buildUnreadMessage(items));
}); }).catch(reject);
}); });
}).finally(() => (loadingChatList = false)); }).finally(() => (loadingChatList = false));
...@@ -542,7 +542,7 @@ export default { ...@@ -542,7 +542,7 @@ export default {
{ dispatch }, { dispatch },
p: { chat: number; unread: number } p: { chat: number; unread: number }
) { ) {
dbController return dbController
.updateChat4UnreadCount(p.chat, p.unread) .updateChat4UnreadCount(p.chat, p.unread)
.then(() => .then(() =>
dispatch(ChatStore.ACTION_REBUILD_UNREAD_MESSAGE_COUNT) dispatch(ChatStore.ACTION_REBUILD_UNREAD_MESSAGE_COUNT)
...@@ -922,7 +922,7 @@ export default { ...@@ -922,7 +922,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);
}) })
); );
...@@ -1179,8 +1179,8 @@ export default { ...@@ -1179,8 +1179,8 @@ export default {
p.read_count = option.all p.read_count = option.all
? p.total_read_count ? p.total_read_count
: option.readed : option.readed
? option.readed ? option.readed
: p.read_count + 1; : p.read_count + 1;
} }
} }
} else { } else {
...@@ -1189,8 +1189,8 @@ export default { ...@@ -1189,8 +1189,8 @@ export default {
p.read_count = option.all p.read_count = option.all
? p.total_read_count ? p.total_read_count
: option.readed : option.readed
? option.readed ? option.readed
: p.read_count + 1; : p.read_count + 1;
} }
} }
} }
......
...@@ -387,7 +387,7 @@ export namespace ChatStore { ...@@ -387,7 +387,7 @@ export namespace ChatStore {
export type ACTION_UPDATE_CHAT_UNREAD_MESSAGE_COUNT = (p: { export type ACTION_UPDATE_CHAT_UNREAD_MESSAGE_COUNT = (p: {
chat: number; chat: number;
unread: number; unread: number;
}) => void; }) => Promise<void>;
} }
export interface ChatStoreState { export interface ChatStoreState {
......
...@@ -16,12 +16,16 @@ export async function getChatModelInfo( ...@@ -16,12 +16,16 @@ export async function getChatModelInfo(
) { ) {
const key = `${modelName}-${id}` const key = `${modelName}-${id}`
if (chatInfo[key] && !forceReload) { if (chatInfo[key] && !forceReload) {
return Promise.resolve({ const d = chatInfo[key];
uniplatId: chatInfo[key].row.UniplatChatId.value, if (d.row && d.row.UniplatChatId) {
chat_id: +chatInfo[key].row.UniplatImChatId.value, return Promise.resolve({
uniplat_version: 0, uniplatId: d.row.UniplatChatId.value,
data: chatInfo[key], chat_id: +d.row.UniplatImChatId.value,
}); uniplat_version: 0,
data: d,
});
}
return Promise.resolve({ uniplatId: 0, chat_id: 0, uniplat_version: 0, data: d });
} }
const info = await Chat.getSdk() const info = await Chat.getSdk()
.model(modelName) .model(modelName)
...@@ -29,10 +33,13 @@ export async function getChatModelInfo( ...@@ -29,10 +33,13 @@ export async function getChatModelInfo(
.query(); .query();
const data = info; const data = info;
chatInfo[key] = data; chatInfo[key] = data;
return { if (info.row && info.row.UniplatChatId) {
uniplatId: info.row.UniplatChatId.value, return {
chat_id: Number(info.row.UniplatImChatId.value), uniplatId: info.row.UniplatChatId.value,
uniplat_version: 0, chat_id: Number(info.row.UniplatImChatId.value),
data, uniplat_version: 0,
}; data,
};
}
return { uniplatId: 0, chat_id: 0, uniplat_version: 0, data, };
} }
...@@ -285,7 +285,6 @@ export class Xim { ...@@ -285,7 +285,6 @@ export class Xim {
kind: string, kind: string,
listener: ChatNotifyListener listener: ChatNotifyListener
): this; ): this;
public on(event: "chat_notify", listener: ChatNotifyListener): this; public on(event: "chat_notify", listener: ChatNotifyListener): this;
public on(event: "status", listener: StatusChangeListener): this; public on(event: "status", listener: StatusChangeListener): this;
public on(...args: any[]): this { public on(...args: any[]): this {
...@@ -306,7 +305,6 @@ export class Xim { ...@@ -306,7 +305,6 @@ export class Xim {
kind: string, kind: string,
listener: ChatNotifyListener listener: ChatNotifyListener
): this; ): this;
public off(event: "chat_notify", listener: ChatNotifyListener): this; public off(event: "chat_notify", listener: ChatNotifyListener): this;
public off(event: "status", listener: StatusChangeListener): this; public off(event: "status", listener: StatusChangeListener): this;
public off(...args: any[]): this { public off(...args: any[]): this {
......
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