Skip to content

Commit

Permalink
Update ot-client.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
yanmao committed Nov 4, 2021
1 parent 81d9454 commit dc02db2
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions examples/vue/src/components/ot-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ import sharedb from 'sharedb/lib/client';
import { Socket } from 'sharedb/lib/sharedb';

export type Member = {
id: number;
avatar: string;
name: string;
iid: number;
uuid: string;
color?: string;
};
Expand Down Expand Up @@ -206,7 +204,8 @@ class OTClient extends EventEmitter {
this.onError({
code: ERROR_CODE.DISCONNECTED,
level: ERROR_LEVEL.FATAL,
message: '网络连接异常,无法继续编辑',
message:
'网络连接异常,无法继续编辑!正在为您重新连接中...',
});
}
});
Expand All @@ -215,7 +214,7 @@ class OTClient extends EventEmitter {
this.onError({
code: ERROR_CODE.CONNECTION_ERROR,
level: ERROR_LEVEL.FATAL,
message: '协作服务异常,无法继续编辑',
message: '协作服务异常,无法继续编辑!正在为您重新连接中...',
error,
});
});
Expand Down Expand Up @@ -306,7 +305,7 @@ class OTClient extends EventEmitter {

addMembers(memberList: Array<Member>) {
memberList.forEach((member) => {
if (!this.members.find((m) => member.id === m.id)) {
if (!this.members.find((m) => member.uuid === m.uuid)) {
this.members.push(member);
}
});
Expand All @@ -332,10 +331,10 @@ class OTClient extends EventEmitter {
const memberMap: any = {};
for (let i = this.members.length; i > 0; i--) {
const member = this.members[i - 1];
if (!memberMap[member.id]) {
if (!memberMap[member.uuid]) {
const cloneMember = { ...member };
cloneMember.color = colorMap[member.uuid];
memberMap[member.id] = member;
memberMap[member.uuid] = member;
members.push(cloneMember);
}
}
Expand Down

0 comments on commit dc02db2

Please sign in to comment.