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
a7604524
authored
Nov 19, 2021
by
Sixong.Zhu
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
u
parent
7216aa65
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
12 deletions
database/index.ts
store/model.ts
database/index.ts
View file @
a7604524
...
...
@@ -16,7 +16,7 @@ class ChatCacheDatabaseController {
private
setuping
=
false
;
private
waitSetupCompleted
()
{
return
new
Promise
<
void
>
(
resolve
=>
{
return
new
Promise
<
void
>
(
(
resolve
)
=>
{
const
checker
=
()
=>
{
if
(
!
this
.
setuping
)
{
resolve
();
...
...
@@ -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
}
`
);
...
...
@@ -158,6 +158,30 @@ class ChatCacheDatabaseController {
p
.
eid
&&
(
chat
.
last_msg_sender
=
p
.
eid
);
p
.
type
&&
(
chat
.
last_msg_type
=
p
.
type
);
p
.
msg
&&
(
chat
.
last_msg_content
=
p
.
msg
);
p
.
set2Read
&&
(
chat
.
unread_msg_count
=
0
);
const
u
=
store
.
put
(
chat
,
chat
.
id
);
u
.
onsuccess
=
()
=>
resolve
();
u
.
onerror
=
()
=>
resolve
();
}
else
{
resolve
();
}
};
t
.
onerror
=
()
=>
resolve
();
}
else
{
resolve
();
}
});
}
public
setRead
(
chat
:
number
)
{
return
new
Promise
<
void
>
((
resolve
)
=>
{
if
(
this
.
db
)
{
const
store
=
this
.
buildStore
(
this
.
chatListKey
);
const
t
=
store
.
get
(
chat
);
t
.
onsuccess
=
(
r
)
=>
{
const
chat
=
(
r
.
target
as
any
).
result
as
Chat
;
if
(
chat
)
{
chat
.
unread_msg_count
=
0
;
const
u
=
store
.
put
(
chat
,
chat
.
id
);
u
.
onsuccess
=
()
=>
resolve
();
u
.
onerror
=
()
=>
resolve
();
...
...
store/model.ts
View file @
a7604524
...
...
@@ -322,9 +322,13 @@ export namespace ChatStore {
export
const
ACTION_TERINATE_CHAT
=
"结束会话"
;
export
type
ACTION_TERINATE_CHAT
=
()
=>
Promise
<
void
>
;
export
const
ACTION_CHAT_ADD_MEMBERS
=
"添加成员"
;
export
type
ACTION_CHAT_ADD_MEMBERS
=
(
uids
:
(
string
|
number
)[])
=>
Promise
<
void
>
;
export
type
ACTION_CHAT_ADD_MEMBERS
=
(
uids
:
(
string
|
number
)[]
)
=>
Promise
<
void
>
;
export
const
ACTION_CHAT_REMOVE_MEMBER
=
"移除成员"
;
export
type
ACTION_CHAT_REMOVE_MEMBER
=
(
uids
:
(
string
|
number
)[])
=>
Promise
<
void
>
;
export
type
ACTION_CHAT_REMOVE_MEMBER
=
(
uids
:
(
string
|
number
)[]
)
=>
Promise
<
void
>
;
export
const
ACTION_CHAT_ADD_CS
=
"添加客服"
;
export
type
ACTION_CHAT_ADD_CS
=
(
uids
:
string
[])
=>
Promise
<
void
>
;
...
...
@@ -352,8 +356,10 @@ export namespace ChatStore {
export
const
ACTION_SET_CHAT_ERROR
=
"标记会话关键性错误"
;
export
type
ACTION_SET_CHAT_ERROR
=
(
chat
:
number
)
=>
void
;
export
const
ACTION_GET_USERINFO
=
'获取用户个人信息'
;
export
type
ACTION_GET_USERINFO
=
(
id
:
string
)
=>
Promise
<
{
id
:
string
;
name
:
string
}
>
export
const
ACTION_GET_USERINFO
=
"获取用户个人信息"
;
export
type
ACTION_GET_USERINFO
=
(
id
:
string
)
=>
Promise
<
{
id
:
string
;
name
:
string
}
>
;
export
interface
ChatUpdateParameter
{
chat
:
number
;
...
...
@@ -361,7 +367,7 @@ export namespace ChatStore {
msg
?:
string
;
ts
?:
number
;
eid
?:
string
;
unread
?:
number
;
set2Read
?:
boolean
;
}
export
const
ACTION_UPDATE_CHAT
=
"更新会话信息"
;
...
...
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