-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(frontend): crash on empty planned events (#87)
- Loading branch information
Showing
10 changed files
with
101 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { getTransaction } from "./get-transaction"; | ||
import type { IStorageName } from "./types"; | ||
|
||
export async function countIndexedDBItems( | ||
storeName: IStorageName, | ||
): Promise<number> { | ||
const resultCount = await new Promise<number>((resolve, reject) => { | ||
getTransaction([storeName], "readonly").then((transaction) => { | ||
transaction.onerror = (event) => { | ||
reject(event); | ||
}; | ||
|
||
const objectStore = transaction.objectStore(storeName); | ||
const countRequest = objectStore.count(); | ||
|
||
countRequest.onsuccess = (event) => { | ||
const count = (event.target as typeof countRequest).result; | ||
|
||
resolve(count); | ||
} | ||
}); | ||
}); | ||
|
||
return resultCount | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { getTransaction } from "./get-transaction"; | ||
import type { IStorageName } from "./types"; | ||
|
||
export async function getOneIndexedDBItem<Type>( | ||
storeName: IStorageName, | ||
query: IDBValidKey, | ||
validate: (input: unknown) => asserts input is Type, | ||
): Promise<Type> { | ||
const result = await new Promise((resolve, reject) => { | ||
getTransaction([storeName], "readonly").then((transaction) => { | ||
const objectStore = transaction.objectStore(storeName); | ||
const request = objectStore.get(query); | ||
|
||
request.onerror = (event) => { | ||
reject(event); | ||
}; | ||
|
||
request.onsuccess = (event) => { | ||
const result: unknown = (event.target as typeof request).result; | ||
|
||
resolve(result); | ||
}; | ||
}); | ||
}); | ||
|
||
validate(result); | ||
|
||
return result; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters