Skip to content

Commit

Permalink
Removes Filter Key if Empty Array
Browse files Browse the repository at this point in the history
Fixes #105
  • Loading branch information
Step7750 committed Oct 5, 2022
1 parent 74cab29 commit f41363d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/lib/filter/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {getDopplerPhase} from "../utils/dopplers";
import {ReplaySubject} from "rxjs";
import {debounce} from "lodash-decorators";
import {averageColour} from "./utils";
import {Remove} from "../bridge/handlers/storage_remove";


/**
Expand Down Expand Up @@ -109,8 +110,13 @@ class FilterService {

const iFilters = this.filters.filter(f => !f.getIsGlobal()).map(f => f.serialize());

// TODO(GH-105): If this is an empty array, we can just delete the key
await Set(this.itemRow, iFilters);
if (iFilters.length === 0) {
// Remove the key to prevent polluting their storage
// Sync storage has a max of 512 keys which we don't want to hit easily
await Remove(this.itemRow);
} else {
await Set(this.itemRow, iFilters);
}

}
}
Expand Down

0 comments on commit f41363d

Please sign in to comment.