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
06753eae
authored
Nov 16, 2021
by
Sixong.Zhu
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
control setup
parent
eb042a64
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
0 deletions
database/index.ts
database/index.ts
View file @
06753eae
...
@@ -13,9 +13,28 @@ class ChatCacheDatabaseController {
...
@@ -13,9 +13,28 @@ class ChatCacheDatabaseController {
private
readonly
chatListKey
=
"chat-list"
;
private
readonly
chatListKey
=
"chat-list"
;
private
readonly
chatMessageKey
=
"chat-message"
;
private
readonly
chatMessageKey
=
"chat-message"
;
private
setuping
=
false
;
private
waitSetupCompleted
()
{
return
new
Promise
<
void
>
(
resolve
=>
{
const
checker
=
()
=>
{
if
(
!
this
.
setuping
)
{
resolve
();
}
else
{
setTimeout
(()
=>
checker
(),
200
);
}
};
checker
();
});
}
public
setup
(
uid
:
string
)
{
public
setup
(
uid
:
string
)
{
if
(
this
.
setuping
)
{
return
this
.
waitSetupCompleted
();
}
return
new
Promise
<
void
>
((
resolve
)
=>
{
return
new
Promise
<
void
>
((
resolve
)
=>
{
if
(
uid
&&
indexedDB
)
{
if
(
uid
&&
indexedDB
)
{
this
.
setuping
=
true
;
const
r
=
indexedDB
.
open
(
const
r
=
indexedDB
.
open
(
"u-"
+
(
this
.
uid
=
uid
),
"u-"
+
(
this
.
uid
=
uid
),
this
.
listVersion
this
.
listVersion
...
@@ -33,6 +52,7 @@ class ChatCacheDatabaseController {
...
@@ -33,6 +52,7 @@ class ChatCacheDatabaseController {
console
.
error
(
e
);
console
.
error
(
e
);
}
}
}
}
this
.
setuping
=
false
;
resolve
();
resolve
();
};
};
r
.
onsuccess
=
function
(
e
)
{
r
.
onsuccess
=
function
(
e
)
{
...
...
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