Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix IndexedDBStore API documentation #3987

Merged
merged 2 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ Changes in [30.0.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v30

## 🚨 BREAKING CHANGES
* Refactor & make base64 functions browser-safe ([\#3818](https://github.com/matrix-org/matrix-js-sdk/pull/3818)).
* `IndexedDBStore.startup()` must be called after using it on `sdk.createClient` now.

## 🦖 Deprecations
* Deprecate `MatrixEvent.toJSON` ([\#3801](https://github.com/matrix-org/matrix-js-sdk/pull/3801)).
Expand Down
6 changes: 4 additions & 2 deletions src/store/indexeddb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ export class IndexedDBStore extends MemoryStore {
* ```
* let opts = { indexedDB: window.indexedDB, localStorage: window.localStorage };
* let store = new IndexedDBStore(opts);
* await store.startup(); // load from indexed db
* let client = sdk.createClient({
* store: store,
* });
* await store.startup(); // load from indexed db, must be called after createClient
* client.startClient();
* client.on("sync", function(state, prevState, data) {
* if (state === "PREPARED") {
Expand Down Expand Up @@ -140,7 +140,9 @@ export class IndexedDBStore extends MemoryStore {
logger.log(`IndexedDBStore.startup: processing presence events`);
userPresenceEvents.forEach(([userId, rawEvent]) => {
if (!this.createUser) {
throw new Error("createUser is undefined, it should be set with setUserCreator()!");
throw new Error(
"`IndexedDBStore.startup` must be called after assigning it to the client, not before!",
);
}
const u = this.createUser(userId);
if (rawEvent) {
Expand Down
Loading