Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
foreign
/
customer-service
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
1f36149b
authored
Dec 01, 2021
by
Sixong.Zhu
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
merged from master
parent
dd30d794
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
179 additions
and
27 deletions
components/message.vue
components/who-read-list.vue
database/index.ts
store/index.ts
store/model.ts
components/message.vue
View file @
1f36149b
...
...
@@ -195,9 +195,6 @@
@
chatStore
.
Getter
(
ChatStore
.
GETTER_CURRENT_CHAT_PRESENT_MEMBERS
)
private
readonly
chatMembers
!
:
ChatStore
.
GETTER_CURRENT_CHAT_PRESENT_MEMBERS
;
@
chatStore
.
State
(
ChatStore
.
STATE_CHAT_SOURCE
)
private
readonly
chatSource
!
:
ChatStore
.
STATE_CHAT_SOURCE
;
@
chatStore
.
State
(
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
)
private
readonly
chatId
!
:
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
;
...
...
@@ -294,10 +291,6 @@
return
senderEid
!
.
toString
()
===
this
.
chatMyId
!
.
toString
();
}
created
()
{
this
.
messageComponent
=
messageMapping
.
get
(
this
.
messageType
)
as
string
;
}
private
get
userName
()
{
if
(
this
.
chatMembers
)
{
const
t
=
this
.
chatMembers
.
find
((
i
)
=>
i
.
eid
===
this
.
data
.
eid
);
...
...
@@ -395,6 +388,10 @@
return
false
;
}
created
()
{
this
.
messageComponent
=
messageMapping
.
get
(
this
.
messageType
)
as
string
;
}
private
isCustomer
()
{
return
!
this
.
showReadSummary
;
}
...
...
components/who-read-list.vue
View file @
1f36149b
...
...
@@ -70,6 +70,9 @@
@
chatStoreNamespace
.
State
(
ChatStore
.
STATE_CHAT_MY_ID
)
private
readonly
chatMyId
!
:
ChatStore
.
STATE_CHAT_MY_ID
;
@
chatStoreNamespace
.
Action
(
ChatStore
.
ACTION_UPDATE_MESSAGE_READ_STATUS
)
private
readonly
updateMessage
!
:
ChatStore
.
ACTION_UPDATE_MESSAGE_READ_STATUS
;
@
Prop
({
type
:
Number
})
private
msgId
!
:
number
;
...
...
@@ -153,6 +156,14 @@
};
})
);
if
(
!
this
.
unreadlist
.
length
)
{
this
.
updateMessage
({
chat
:
this
.
chatId
,
start
:
this
.
msgId
,
all
:
true
,
});
}
}
private
uniqueReaderList
(
data
:
dto
.
OneWhoReadMessage
[])
{
...
...
database/index.ts
View file @
1f36149b
...
...
@@ -57,17 +57,17 @@ class ChatCacheDatabaseController {
}
resolve
();
};
r
.
onsuccess
=
function
(
e
)
{
r
.
onsuccess
=
function
(
e
)
{
that
.
db
=
(
e
.
target
as
any
).
result
;
console
.
log
(
`index database init comepleted`
);
setupDb
();
};
r
.
onupgradeneeded
=
function
(
e
)
{
r
.
onupgradeneeded
=
function
(
e
)
{
that
.
db
=
(
e
.
target
as
any
).
result
;
console
.
log
(
`upgrade database comepleted`
);
setupDb
();
};
r
.
onerror
=
function
(
e
)
{
r
.
onerror
=
function
(
e
)
{
console
.
log
(
`index database init failed,
${
e
}
`
);
};
}
else
{
...
...
@@ -94,17 +94,17 @@ class ChatCacheDatabaseController {
}
setTimeout
(()
=>
resolve
(),
200
);
};
r
.
onsuccess
=
function
(
e
)
{
r
.
onsuccess
=
function
(
e
)
{
const
db
=
(
e
.
target
as
any
).
result
;
that
.
messageDatabases
.
set
(
k
,
db
);
setupDb
();
};
r
.
onupgradeneeded
=
function
(
e
)
{
r
.
onupgradeneeded
=
function
(
e
)
{
const
db
=
(
e
.
target
as
any
).
result
;
that
.
messageDatabases
.
set
(
k
,
db
);
setupDb
();
};
r
.
onerror
=
function
(
e
)
{
r
.
onerror
=
function
(
e
)
{
console
.
log
(
`chat message index database init failed,
${
e
}
`
);
...
...
@@ -196,6 +196,75 @@ class ChatCacheDatabaseController {
});
}
public
setMessageReaded
(
chat
:
number
,
option
:
{
/**
* 要更新已读状态的消息Id
*/
start
:
number
;
/**
* 如果此值存在且大于 start ,则表示需要更新从 [start ~ end] 这个区间内所有消息的已读状态
*/
end
?:
number
;
/**
* 如果此值为true,则标记此条消息被所有人已读,否则只会在现有已读数上+1
*/
allRead
?:
boolean
;
}
)
{
return
new
Promise
<
void
>
((
resolve
)
=>
{
if
(
this
.
db
)
{
const
store
=
this
.
buildChatMessageStore
(
chat
);
if
(
option
.
end
&&
option
.
end
>
option
.
start
)
{
const
total
=
option
.
end
-
option
.
start
;
let
finished
=
0
;
const
onCompleted
=
()
=>
{
finished
++
;
if
(
finished
>=
total
)
{
resolve
();
}
};
for
(
let
i
=
option
.
start
;
i
<=
option
.
end
;
i
++
)
{
const
r
=
store
.
get
(
i
);
r
.
onsuccess
=
(
m
)
=>
{
const
p
=
(
m
.
target
as
any
).
result
as
Message
;
if
(
p
)
{
if
(
option
.
allRead
)
{
p
.
read_count
=
p
.
total_read_count
;
}
else
{
p
.
read_count
++
;
}
store
.
put
(
p
).
onsuccess
=
()
=>
onCompleted
();
}
else
{
onCompleted
();
}
};
r
.
onerror
=
()
=>
onCompleted
();
}
}
else
{
const
r
=
store
.
get
(
option
.
start
);
r
.
onsuccess
=
(
m
)
=>
{
const
p
=
(
m
.
target
as
any
).
result
as
Message
;
if
(
p
)
{
if
(
option
.
allRead
)
{
p
.
read_count
=
p
.
total_read_count
;
}
else
{
p
.
read_count
++
;
}
store
.
put
(
p
).
onsuccess
=
()
=>
resolve
();
}
else
{
resolve
();
}
};
r
.
onerror
=
()
=>
resolve
();
}
}
else
{
resolve
();
}
});
}
public
removeChatFromList
(
chat
:
number
)
{
return
new
Promise
<
void
>
((
resolve
)
=>
{
if
(
this
.
db
)
{
...
...
store/index.ts
View file @
1f36149b
...
...
@@ -480,7 +480,9 @@ export default {
},
async
[
ChatStore
.
ACTION_GET_CHAT_MESSAGES
]({
state
,
commit
,
getters
})
{
const
chatId
=
state
[
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
];
const
chat
=
getters
[
ChatStore
.
GETTER_CURRENT_CURRENT_CHAT
];
const
chat
=
getters
[
ChatStore
.
GETTER_CURRENT_CURRENT_CHAT
]
as
ChatType
;
const
isMember
=
state
[
ChatStore
.
STATE_CHAT_CURRENT_IS_CHAT_MEMBER
];
if
(
chatId
==
null
)
return
;
let
data
:
Message
[]
=
[];
...
...
@@ -520,7 +522,9 @@ export default {
)
{
const
chatId
=
state
[
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
];
if
(
chatId
==
null
)
return
;
const
chat
=
getters
[
ChatStore
.
GETTER_CURRENT_CURRENT_CHAT
];
const
chat
=
getters
[
ChatStore
.
GETTER_CURRENT_CURRENT_CHAT
]
as
ChatType
;
const
o
=
{
model
:
chat
.
model_name
,
obj
:
chat
.
obj_id
,
...
...
@@ -543,7 +547,9 @@ export default {
)
{
const
chatId
=
state
[
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
];
if
(
chatId
==
null
)
return
;
const
chat
=
getters
[
ChatStore
.
GETTER_CURRENT_CURRENT_CHAT
];
const
chat
=
getters
[
ChatStore
.
GETTER_CURRENT_CURRENT_CHAT
]
as
ChatType
;
const
o
=
{
model
:
chat
.
model_name
,
obj
:
chat
.
obj_id
,
...
...
@@ -570,7 +576,9 @@ export default {
}
}
try
{
const
chat
=
getters
[
ChatStore
.
GETTER_CURRENT_CURRENT_CHAT
];
const
chat
=
getters
[
ChatStore
.
GETTER_CURRENT_CURRENT_CHAT
]
as
ChatType
;
const
data
=
await
Chat
.
getSdk
()
.
model
(
chat
.
model_name
)
.
chat
(
chat
.
obj_id
,
orgId
())
...
...
@@ -665,22 +673,29 @@ export default {
if
(
msgs
==
null
)
return
;
const
oldestMsgId
=
msgs
[
0
].
id
-
1
;
const
lastMsgId
=
msgs
[
msgs
.
length
-
1
].
id
+
1
;
const
chat
=
getters
[
ChatStore
.
GETTER_CURRENT_CURRENT_CHAT
];
const
chat
=
getters
[
ChatStore
.
GETTER_CURRENT_CURRENT_CHAT
]
as
ChatType
;
const
o
=
{
model
:
chat
.
model_name
,
obj
:
chat
.
obj_id
,
isMember
:
state
[
ChatStore
.
STATE_CHAT_CURRENT_IS_CHAT_MEMBER
],
};
const
start
=
oldestMsgId
<
1
?
1
:
oldestMsgId
;
const
freshMsgs
=
await
xim
.
queryMsgs
(
chatType
,
chatId
,
oldestMsgId
<
1
?
1
:
oldestMsgId
,
start
,
lastMsgId
,
20
,
true
,
o
);
dbController
.
setMessageReaded
(
chatId
,
{
start
,
end
:
lastMsgId
,
});
commit
(
ChatStore
.
MUTATION_CLEAR_CHAT_MSG_HISTORY
);
commit
(
ChatStore
.
MUTATION_PUSH_CHAT_MSG_HISTORY
,
...
...
@@ -854,7 +869,9 @@ export default {
);
},
async
[
ChatStore
.
ACTION_CHAT_START_RECEPTION
]({
getters
,
dispatch
})
{
const
currentChat
=
getters
[
ChatStore
.
GETTER_CURRENT_CURRENT_CHAT
];
const
currentChat
=
getters
[
ChatStore
.
GETTER_CURRENT_CURRENT_CHAT
]
as
ChatType
;
if
(
!
currentChat
||
!
currentChat
.
model_name
||
...
...
@@ -869,7 +886,9 @@ export default {
.
finally
(()
=>
dispatch
(
ChatStore
.
ACTION_GET_CHAT_MEMBERS
));
},
async
[
ChatStore
.
ACTION_CHAT_FINISH_RECEPTION
]({
getters
,
dispatch
})
{
const
currentChat
=
getters
[
ChatStore
.
GETTER_CURRENT_CURRENT_CHAT
];
const
currentChat
=
getters
[
ChatStore
.
GETTER_CURRENT_CURRENT_CHAT
]
as
ChatType
;
if
(
!
currentChat
||
!
currentChat
.
model_name
||
...
...
@@ -884,7 +903,9 @@ export default {
.
finally
(()
=>
dispatch
(
ChatStore
.
ACTION_GET_CHAT_MEMBERS
));
},
async
[
ChatStore
.
ACTION_CHAT_USER_EXIT
]({
getters
,
dispatch
})
{
const
currentChat
=
getters
[
ChatStore
.
GETTER_CURRENT_CURRENT_CHAT
];
const
currentChat
=
getters
[
ChatStore
.
GETTER_CURRENT_CURRENT_CHAT
]
as
ChatType
;
if
(
!
currentChat
||
!
currentChat
.
model_name
||
...
...
@@ -899,7 +920,9 @@ export default {
.
finally
(()
=>
dispatch
(
ChatStore
.
ACTION_GET_CHAT_MEMBERS
));
},
async
[
ChatStore
.
ACTION_CHAT_CS_EXIT
]({
getters
,
dispatch
})
{
const
currentChat
=
getters
[
ChatStore
.
GETTER_CURRENT_CURRENT_CHAT
];
const
currentChat
=
getters
[
ChatStore
.
GETTER_CURRENT_CURRENT_CHAT
]
as
ChatType
;
if
(
!
currentChat
||
!
currentChat
.
model_name
||
...
...
@@ -917,7 +940,9 @@ export default {
{
getters
,
dispatch
},
uids
:
Parameters
<
ChatStore
.
ACTION_CHAT_ADD_MEMBERS
>
[
0
]
)
{
const
currentChat
=
getters
[
ChatStore
.
GETTER_CURRENT_CURRENT_CHAT
];
const
currentChat
=
getters
[
ChatStore
.
GETTER_CURRENT_CURRENT_CHAT
]
as
ChatType
;
if
(
!
currentChat
||
!
currentChat
.
model_name
||
...
...
@@ -935,7 +960,9 @@ export default {
{
getters
,
dispatch
},
uids
:
Parameters
<
ChatStore
.
ACTION_CHAT_REMOVE_MEMBER
>
[
0
]
)
{
const
currentChat
=
getters
[
ChatStore
.
GETTER_CURRENT_CURRENT_CHAT
];
const
currentChat
=
getters
[
ChatStore
.
GETTER_CURRENT_CURRENT_CHAT
]
as
ChatType
;
if
(
!
currentChat
||
!
currentChat
.
model_name
||
...
...
@@ -953,7 +980,9 @@ export default {
{
getters
,
dispatch
},
uids
:
Parameters
<
ChatStore
.
ACTION_CHAT_ADD_CS
>
[
0
]
)
{
const
currentChat
=
getters
[
ChatStore
.
GETTER_CURRENT_CURRENT_CHAT
];
const
currentChat
=
getters
[
ChatStore
.
GETTER_CURRENT_CURRENT_CHAT
]
as
ChatType
;
if
(
!
currentChat
||
!
currentChat
.
model_name
||
...
...
@@ -971,7 +1000,9 @@ export default {
{
getters
,
dispatch
},
uids
:
Parameters
<
ChatStore
.
ACTION_CHAT_REMOVE_CS
>
[
0
]
)
{
const
currentChat
=
getters
[
ChatStore
.
GETTER_CURRENT_CURRENT_CHAT
];
const
currentChat
=
getters
[
ChatStore
.
GETTER_CURRENT_CURRENT_CHAT
]
as
ChatType
;
if
(
!
currentChat
||
!
currentChat
.
model_name
||
...
...
@@ -1033,6 +1064,42 @@ export default {
.
catch
(
reject
)
);
},
[
ChatStore
.
ACTION_UPDATE_MESSAGE_READ_STATUS
]:
(
{
state
},
option
:
{
chat
:
number
;
start
:
number
;
end
?:
number
;
all
?:
boolean
;
}
)
=>
{
const
items
=
state
[
ChatStore
.
STATE_CHAT_MSG_HISTORY
]
as
Message
[];
if
(
items
)
{
if
(
option
.
end
&&
option
.
end
>
option
.
start
)
{
for
(
let
i
=
option
.
start
;
i
<=
option
.
end
;
i
++
)
{
const
p
=
items
.
find
((
m
)
=>
m
.
id
===
i
);
if
(
p
)
{
p
.
read_count
=
option
.
all
?
p
.
total_read_count
:
p
.
read_count
+
1
;
}
}
}
else
{
const
p
=
items
.
find
((
i
)
=>
i
.
id
===
option
.
start
);
if
(
p
)
{
p
.
read_count
=
option
.
all
?
p
.
total_read_count
:
p
.
read_count
+
1
;
}
}
}
return
dbController
.
setMessageReaded
(
option
.
chat
,
{
start
:
option
.
start
,
end
:
option
.
end
,
allRead
:
option
.
all
,
});
},
},
getters
:
{
[
ChatStore
.
STATE_CHAT_MSG_HISTORY
](
state
)
{
...
...
store/model.ts
View file @
1f36149b
...
...
@@ -358,6 +358,14 @@ export namespace ChatStore {
id
:
string
)
=>
Promise
<
{
id
:
string
;
name
:
string
}
>
;
export
const
ACTION_UPDATE_MESSAGE_READ_STATUS
=
"更新消息已读状态"
;
export
type
ACTION_UPDATE_MESSAGE_READ_STATUS
=
(
option
:
{
chat
:
number
;
start
:
number
;
end
?:
number
;
all
?:
boolean
;
})
=>
Promise
<
void
>
;
export
interface
ChatUpdateParameter
{
chat
:
number
;
type
?:
dto
.
MessageType
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment