Skip to content

Commit

Permalink
feat: peopleToSave capped at 100 due to 5mb limit
Browse files Browse the repository at this point in the history
  • Loading branch information
Acorn221 committed Dec 9, 2023
1 parent 039a47a commit 7183e64
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/background/PeopleHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { debug } from '~src/misc/config';
import type { Person, ProfileResponseData, UserStats } from '~src/misc/tinderTypes';

const maxPeopleToStore = 1000;
const maxPeopleToSave = 100;

export type photoInfo = {
hqUrl: string;
Expand Down Expand Up @@ -69,7 +70,7 @@ export class PeopleHandler {

this.storage.get<PersonWithAddedAt[]>('people').then((data) => {
if (!data) return;
this.people = [...this.people, ...data];
this.handleNewPeople(data);
});
}

Expand Down Expand Up @@ -157,7 +158,11 @@ export class PeopleHandler {
}

async savePeople() {
await this.storage.set('people', this.people);
// storage limit of 5MB so we can't save everyone ;(
const peopleToSave = this.people
.sort((a, b) => b.addedAt - a.addedAt)
.slice(0, maxPeopleToSave);
await this.storage.set('people', peopleToSave);
}

async handleProfile(profile: ProfileResponseData) {
Expand Down

0 comments on commit 7183e64

Please sign in to comment.