Commit 77f708a6 by 杨铁龙

indexdb orgid 使用传入的orgid

parent d940313d
Showing with 11 additions and 12 deletions
......@@ -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}`
);
......
......@@ -59,7 +59,7 @@ class Chat implements ChatMessageController {
option.avatar !== undefined &&
(this.defaultAvatar = option.avatar);
await this.setupIndexDb();
await this.setupIndexDb(option.orgId());
this.token = async () => option.sdk().global.jwtToken;
tokenManager.save(this.token);
......@@ -83,12 +83,11 @@ class Chat implements ChatMessageController {
});
}
private setupIndexDb() {
private setupIndexDb(orgId: number | string) {
if (this._sdk) {
const s = this._sdk();
return dbController.setup(
s.global.uid + "-" + (s.global.initData.orgId || 0)
);
const key = `${s.global.uid}-${orgId || 0}`
return dbController.setup(key);
}
return Promise.reject(new Error("Sdk is not defined"));
}
......@@ -96,7 +95,7 @@ class Chat implements ChatMessageController {
public resetup(org: () => string | number) {
this._orgId = org;
xim.onConnected();
return this.setupIndexDb();
return this.setupIndexDb(org());
}
public unSetup() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment