Skip to content

Commit

Permalink
Merge pull request #2785 from GetStream/fix/db-open-close-issues
Browse files Browse the repository at this point in the history
fix: db open close issues
  • Loading branch information
isekovanic authored Nov 15, 2024
2 parents f667148 + d353d32 commit e029830
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion examples/SampleApp/src/hooks/useChatClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ export const useChatClient = () => {
};

const logout = async () => {
SqliteClient.resetDB();
await SqliteClient.resetDB();
setChatClient(null);
chatClient?.disconnectUser();
await AsyncStore.removeItem('@stream-rn-sampleapp-login-config');
Expand Down
6 changes: 5 additions & 1 deletion package/src/store/SqliteClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export class SqliteClient {
throw new Error('DB is not open or initialized.');
}
this.db.close();
this.db = undefined;
} catch (e) {
this.logger?.('error', `Error closing database ${SqliteClient.dbName}`, {
error: e,
Expand Down Expand Up @@ -200,7 +201,10 @@ export class SqliteClient {

static resetDB = async () => {
this.logger?.('info', `resetDB`);
SqliteClient.dropTables();
if (this.db) {
await SqliteClient.dropTables();
SqliteClient.closeDB();
}
await SqliteClient.initializeDatabase();
};
}

0 comments on commit e029830

Please sign in to comment.