1.0.5 • Published 5 years ago

dcd-im v1.0.5

Weekly downloads
4
License
MIT
Repository
github
Last release
5 years ago
  1. 在分发消息的时候,无论在初始化时在消息列表,还是 poll 分发的新会话都必须调用 open 接口,所以 updateConversationList 函数改为异步。
async updateConversationList(data, init = true, key = 'conversationId') {
    const inits = [];
    for (const item of data) {
        this.index++;
        item.index = this.index;
        if (!this.conversationList[item[key]]) {
            const conversation = new Conversation(item);
            this.conversationList[item[key]] = conversation;
            if (init) {
                inits.push(this.conversationList[item[key]].init(this.initConversation));
            }
        }
    }
    await Promise.all(inits);
    this.updateConversations(this.conversationList);
    return this;
}

使用方式

await window.IM.updateConversationList(message);
window.IM.updateConversationList(message).then();
  1. 当 poll 到会话列表的时候,分发消息的顺序要保证, 先分发新会话,再分发消息,再移除会话。
// 分发消息
    async dispatch(message) {
        if (message) {
            message = message.map(val => ({
                ...val.msg,
                id: val.id,
                msgId: val.msg.id,
                type: val.type,
                guest: val.guest,
                ip: val.ip,
            }));
            const chatmessage = message.filter(val => val.type === 1);
            const conversations = message.filter(val => val.type === 2);
            const endTalks = message.filter(val => val.type === 3);
            await addConversation.call(this, conversations);
            dispatchMessage.call(this, chatmessage);
            removeConversation.call(this, endTalks);
        }
    }

3.对 poll 函数做了优化,内部自行判断是否在 polling 阶段,如果在,再次调用 poll 函数无效。

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago