aboutsummaryrefslogtreecommitdiff
path: root/Timeline/ClientApp/src/app/services/common.ts
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2020-09-01 02:32:06 +0800
committercrupest <crupest@outlook.com>2020-09-01 02:32:06 +0800
commita314b5350e269676e8c39eda4cc7842751b1a7fc (patch)
treeab3e8c96f18c8e9f6e8c613ace0e04329614304c /Timeline/ClientApp/src/app/services/common.ts
parent02a9bf9ecfe1659b3481a5386e7a06ee2f0e5fc5 (diff)
downloadtimeline-a314b5350e269676e8c39eda4cc7842751b1a7fc.tar.gz
timeline-a314b5350e269676e8c39eda4cc7842751b1a7fc.tar.bz2
timeline-a314b5350e269676e8c39eda4cc7842751b1a7fc.zip
...
Diffstat (limited to 'Timeline/ClientApp/src/app/services/common.ts')
-rw-r--r--Timeline/ClientApp/src/app/services/common.ts23
1 files changed, 23 insertions, 0 deletions
diff --git a/Timeline/ClientApp/src/app/services/common.ts b/Timeline/ClientApp/src/app/services/common.ts
new file mode 100644
index 00000000..3bb6b9d7
--- /dev/null
+++ b/Timeline/ClientApp/src/app/services/common.ts
@@ -0,0 +1,23 @@
+import localforage from "localforage";
+
+import { HttpNetworkError } from "@/http/common";
+
+export const dataStorage = localforage.createInstance({
+ name: "data",
+ description: "Database for offline data.",
+ driver: localforage.INDEXEDDB,
+});
+
+export class ForbiddenError extends Error {
+ constructor(message?: string) {
+ super(message);
+ }
+}
+
+export function throwIfNotNetworkError(e: unknown): void {
+ if (!(e instanceof HttpNetworkError)) {
+ throw e;
+ }
+}
+
+export type BlobOrStatus = Blob | "loading" | "error";