Skip to content

Commit

Permalink
Remove unused file, add isQuotaExceededError helper fn
Browse files Browse the repository at this point in the history
  • Loading branch information
rzvdv committed Jun 15, 2022
1 parent 320b224 commit a544726
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 137 deletions.
132 changes: 0 additions & 132 deletions src/__tests__/helpers/heatmapCreator.test.ts

This file was deleted.

3 changes: 3 additions & 0 deletions src/helpers/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@

export const isAbortError = (error: unknown): boolean =>
error instanceof DOMException && error.code === error.ABORT_ERR;

export const isQuotaExceededError = (error: unknown): boolean =>
error instanceof DOMException && error.code === error.QUOTA_EXCEEDED_ERR;
3 changes: 2 additions & 1 deletion src/stores/BookmarksStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { DbData, IndexedDB, indexedDbLimits, IndexedDbStores } from '../api/inde
import notificationsStore from './NotificationsStore';
import { Bookmark, BookmarkType, EventBookmark, MessageBookmark } from '../models/Bookmarks';
import { isEventBookmark, isMessageBookmark } from '../helpers/bookmarks';
import { isQuotaExceededError } from '../helpers/fetch';

export class BookmarksStore {
@observable.shallow
Expand Down Expand Up @@ -183,7 +184,7 @@ export class BookmarksStore {
try {
await this.db.addDbStoreItem(store, toJS(bookmark));
} catch (error) {
if (error.name === 'QuotaExceededError') {
if (isQuotaExceededError(error)) {
this.workspacesStore.onQuotaExceededError(bookmark);
} else {
notificationsStore.addMessage({
Expand Down
5 changes: 3 additions & 2 deletions src/stores/MessageBodySortStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { IndexedDB, IndexedDbStores, indexedDbLimits, DbData } from '../api/inde
import { OrderRule, RULES_ORDER_ID } from './MessageDisplayRulesStore';
import notificationsStore from './NotificationsStore';
import { MessageBodyField, MessageBodyFields } from '../models/MessageBody';
import { isQuotaExceededError } from '../helpers/fetch';

class MessageBodySortOrderStore {
constructor(private rootStore: RootStore, private indexedDb: IndexedDB) {
Expand Down Expand Up @@ -127,7 +128,7 @@ class MessageBodySortOrderStore {
try {
await this.indexedDb.addDbStoreItem(IndexedDbStores.MESSAGE_BODY_SORT_ORDER, toJS(rule));
} catch (error) {
if (error instanceof DOMException && error.code === error.QUOTA_EXCEEDED_ERR) {
if (isQuotaExceededError(error)) {
this.rootStore.handleQuotaExceededError(rule);
} else {
notificationsStore.addMessage({
Expand All @@ -145,7 +146,7 @@ class MessageBodySortOrderStore {
try {
await this.indexedDb.updateDbStoreItem(IndexedDbStores.MESSAGE_BODY_SORT_ORDER, toJS(rule));
} catch (error) {
if (error instanceof DOMException && error.code === error.QUOTA_EXCEEDED_ERR) {
if (isQuotaExceededError(error)) {
this.rootStore.handleQuotaExceededError(rule);
} else {
notificationsStore.addMessage({
Expand Down
5 changes: 3 additions & 2 deletions src/stores/MessageDisplayRulesStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import moment from 'moment';
import { nanoid } from 'nanoid';
import { DbData, IndexedDB, indexedDbLimits, IndexedDbStores } from '../api/indexedDb';
import { move } from '../helpers/array';
import { isQuotaExceededError } from '../helpers/fetch';
import {
isMessageDisplayRule,
isOrderRule,
Expand Down Expand Up @@ -179,7 +180,7 @@ class MessageDisplayRulesStore {
try {
await this.indexedDb.addDbStoreItem(IndexedDbStores.DISPLAY_RULES, toJS(rule));
} catch (error) {
if (error.name === 'QuotaExceededError') {
if (isQuotaExceededError(error)) {
this.rootStore.handleQuotaExceededError(rule);
} else {
notificationsStore.addMessage({
Expand All @@ -197,7 +198,7 @@ class MessageDisplayRulesStore {
try {
await this.indexedDb.updateDbStoreItem(IndexedDbStores.DISPLAY_RULES, toJS(rule));
} catch (error) {
if (error.name === 'QuotaExceededError') {
if (isQuotaExceededError(error)) {
this.rootStore.handleQuotaExceededError(rule);
} else {
notificationsStore.addMessage({
Expand Down

0 comments on commit a544726

Please sign in to comment.