Skip to content

Commit

Permalink
remove some now-unnecessary operations
Browse files Browse the repository at this point in the history
  • Loading branch information
3vorp committed Dec 9, 2024
1 parent 80380c2 commit f860ba2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 19 deletions.
8 changes: 2 additions & 6 deletions src/v2/repository/pack.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ export default class PackFirestormRepository implements PackRepository {
async getWithSubmission(id: PackID): Promise<PackAll> {
const pack = await packs.get(id);
const submission = await this.submissionRepo.getById(id).catch<null>(() => null);

// faithful pack with no submission information found
if (!submission) return { ...pack, submission: {} };
return { ...pack, submission };
return { ...pack, submission: submission || {} };
}

async getAllTags(): Promise<string[]> {
Expand Down Expand Up @@ -109,8 +106,7 @@ export default class PackFirestormRepository implements PackRepository {
}

async update(packId: PackID, newPack: CreationPack): Promise<Pack> {
const packWithId = { ...newPack, [ID_FIELD]: packId };
await packs.set(packId, packWithId);
await packs.set(packId, newPack);
return packs.get(packId);
}

Expand Down
17 changes: 7 additions & 10 deletions src/v2/repository/posts.repository.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ID_FIELD, WriteConfirmation } from "firestorm-db";
import { WriteConfirmation } from "firestorm-db";
import { posts } from "../firestorm";
import { CreateWebsitePost, WebsitePost, WebsitePostRepository, WebsitePosts } from "../interfaces";

Expand Down Expand Up @@ -32,17 +32,14 @@ export default class PostFirestormRepository implements WebsitePostRepository {
return results[0];
}

create(postToCreate: CreateWebsitePost): Promise<WebsitePost> {
const { permalink } = postToCreate;
return posts.add(postToCreate).then(() => this.getByPermalink(permalink));
async create(postToCreate: CreateWebsitePost): Promise<WebsitePost> {
await posts.add(postToCreate);
return this.getByPermalink(postToCreate.permalink);
}

update(id: number, post: CreateWebsitePost): Promise<WebsitePost> {
const postWithId = {
...post,
[ID_FIELD]: String(id),
};
return posts.set(id, postWithId).then(() => posts.get(id));
async update(id: number, post: CreateWebsitePost): Promise<WebsitePost> {
await posts.set(id, post);
return posts.get(id);
}

delete(id: number): Promise<WriteConfirmation> {
Expand Down
5 changes: 2 additions & 3 deletions src/v2/repository/submission.repository.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ID_FIELD, WriteConfirmation } from "firestorm-db";
import { WriteConfirmation } from "firestorm-db";
import {
SubmissionRepository,
Submission,
Expand Down Expand Up @@ -40,8 +40,7 @@ export default class SubmissionFirestormRepository implements SubmissionReposito
}

async update(packId: PackID, newPack: Submission): Promise<Submission> {
const packWithId = { ...newPack, [ID_FIELD]: packId };
await submissions.set(packId, packWithId);
await submissions.set(packId, newPack);
return submissions.get(packId);
}

Expand Down

0 comments on commit f860ba2

Please sign in to comment.