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
cf9c45b6
authored
Dec 02, 2021
by
Sixong.Zhu
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
update
parent
483d728f
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
6 deletions
database/index.ts
database/index.ts
View file @
cf9c45b6
...
...
@@ -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
}
`
);
...
...
@@ -173,6 +173,29 @@ class ChatCacheDatabaseController {
});
}
public
updateChat4UnreadCount
(
chat
:
number
,
unread
:
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
=
unread
;
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
)
{
...
...
@@ -351,6 +374,7 @@ class ChatCacheDatabaseController {
for
(
const
item
of
source2
)
{
const
t
=
source1
.
find
((
i
)
=>
i
.
id
===
item
.
id
);
if
(
t
)
{
item
.
unread_msg_count
=
Math
.
max
(
item
.
unread_msg_count
,
t
.
unread_msg_count
);
const
index
=
source1
.
indexOf
(
t
);
source1
[
index
]
=
item
;
}
else
{
...
...
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