Skip to content

Commit

Permalink
chore: remove updateCache method, replace usages with updateCacheEntry
Browse files Browse the repository at this point in the history
  • Loading branch information
louisgrasset committed Nov 20, 2023
1 parent 02c5b8a commit 0c22549
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 32 deletions.
21 changes: 8 additions & 13 deletions src/helpers/cache/save-post-to-cache.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,24 @@
import {
BlueskyCache,
MastodonCache,
Platform,
PostsCache,
} from "../../types/index.js";
import { updateCacheFile } from "./update-cache.js";
import { BlueskyCache, MastodonCache, Platform } from "../../types/index.js";
import { getCachedPosts } from "./get-cached-posts.js";
import { updateCacheEntry } from "./update-cache-entry.js";

interface PostToCache {
cache: PostsCache;
data: MastodonCache | BlueskyCache;
tweetId?: string;
platform: Platform;
}

export const savePostToCache = async ({
cache,
tweetId = "",
data,
platform,
}: PostToCache) => {
const alreadyExistingCachedPostData = cache[tweetId] || {};
await updateCacheFile({
...cache,
const cachedPosts = await getCachedPosts();
const currentPostData = cachedPosts[tweetId] || {};
await updateCacheEntry("posts", {
...cachedPosts,
[tweetId]: {
...alreadyExistingCachedPostData,
...currentPostData,
[platform]: data,
},
});
Expand Down
17 changes: 0 additions & 17 deletions src/helpers/cache/update-cache.ts

This file was deleted.

2 changes: 0 additions & 2 deletions src/services/bluesky-sender.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,7 @@ export const blueskySenderService = async (
}`,
);

const cache = await getCachedPosts();
await savePostToCache({
cache,
tweetId: post.tweet.id,
data: chunkReferences.map((ref) => ({
rkey: ref.rkey,
Expand Down

0 comments on commit 0c22549

Please sign in to comment.