Skip to content

Commit 8fbc421

Browse files
committed
CodeRabbit change 2
1 parent 2a40c5d commit 8fbc421

File tree

7 files changed

+16
-16
lines changed

7 files changed

+16
-16
lines changed

components/wordpress_com/actions/create-post.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export default {
7272
});
7373

7474
} catch (error) {
75-
wordpress.onAxiosCatch("Could not create post", error, warnings);
75+
wordpress.throwCustomError("Could not create post", error, warnings);
7676
};
7777

7878
$.export("$summary", `Post successfully created. ID = ${response?.ID}` + "\n- " + warnings.join("\n- "));

components/wordpress_com/actions/delete-post.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export default {
3838
try {
3939
response = await wordpress.deleteWordpressPost({$, site, postId});
4040
} catch (error) {
41-
wordpress.onAxiosCatch("Could not delete post", error, warnings);
41+
wordpress.throwCustomError("Could not delete post", error, warnings);
4242
};
4343

4444
$.export("$summary", `Post ID = ${response?.ID} successfully deleted.` + "\n- " + warnings.join("\n- "));

components/wordpress_com/actions/upload-media.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export default {
9191

9292
} catch (error) {
9393

94-
wordpress.onAxiosCatch("Failed to upload media", error, warnings);
94+
wordpress.throwCustomError("Failed to upload media", error, warnings);
9595

9696
};
9797
},

components/wordpress_com/common/methods.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ trimIfString(input) {
196196
Determines whether an error originated from your own validation code or from the API request.
197197
Useful for debugging and crafting more helpful error messages.
198198
====================================================================================================== */
199-
onAxiosCatch(mainMessage, error, warnings){
199+
throwCustomError(mainMessage, error, warnings){
200200

201201
const thrower = error?.response?.status ? "API response" : "Internal Code";
202202

components/wordpress_com/sources/new-comment.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ export default {
5656
});
5757

5858
} catch (error) {
59-
wordpress.onAxiosCatch("Failed to fetch comments from WordPress:", error, warnings);
59+
wordpress.throwCustomError("Failed to fetch comments from WordPress:", error, warnings);
6060
}
6161

6262
const comments = response.comments || [];
63-
const lastCommentId = await db.get("lastCommentId");
63+
const lastCommentId = Number(await db.get("lastCommentId"));
6464

6565
// First run: Initialize cursor
6666
if (!lastCommentId) {
@@ -83,9 +83,9 @@ export default {
8383
const newComments = [];
8484

8585
for (const comment of comments) {
86-
if (comment.ID > lastCommentId) {
86+
if (Number(comment.ID) > lastCommentId) {
8787
newComments.push(comment);
88-
if (comment.ID > maxCommentIdTracker) {
88+
if (Number(comment.ID) > maxCommentIdTracker) {
8989
maxCommentIdTracker = comment.ID;
9090
}
9191
}

components/wordpress_com/sources/new-follower.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ export default {
3636
});
3737

3838
} catch (error) {
39-
wordpress.onAxiosCatch("Failed to fetch followers from WordPress:", error, warnings);
39+
wordpress.throwCustomError("Failed to fetch followers from WordPress:", error, warnings);
4040
}
4141

4242
const followers = response.subscribers || [];
4343

44-
const lastFollowerId = await db.get("lastFollowerId");
44+
const lastFollowerId = Number(await db.get("lastFollowerId"));
4545

4646
// First run: Initialize cursor
4747
if (!lastFollowerId) {
@@ -64,9 +64,9 @@ export default {
6464
const newFollowers = [];
6565

6666
for (const follower of followers) {
67-
if (follower.ID > lastFollowerId) {
67+
if (Number(follower.ID) > lastFollowerId) {
6868
newFollowers.push(follower);
69-
if (follower.ID > maxFollowerIdTracker) {
69+
if (Number(follower.ID) > maxFollowerIdTracker) {
7070
maxFollowerIdTracker = follower.ID;
7171
}
7272
}

components/wordpress_com/sources/new-post.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ export default {
5959
});
6060

6161
} catch (error) {
62-
wordpress.onAxiosCatch("Failed to fetch posts from WordPress:", error, warnings);
62+
wordpress.throwCustomError("Failed to fetch posts from WordPress:", error, warnings);
6363
}
6464

6565
const posts = (type === "attachment") ? (response.media || []) : (response.posts || []);
66-
const lastPostId = await db.get("lastPostId");
66+
const lastPostId = Number(await db.get("lastPostId"));
6767

6868

6969
// First run: Initialize cursor
@@ -88,9 +88,9 @@ export default {
8888
const newPosts = [];
8989

9090
for (const post of posts) {
91-
if (post.ID > lastPostId) {
91+
if (Number(post.ID) > lastPostId) {
9292
newPosts.push(post);
93-
if (post.ID > maxPostIdTracker) {
93+
if (Number(post.ID) > maxPostIdTracker) {
9494
maxPostIdTracker = post.ID;
9595
}
9696
}

0 commit comments

Comments
 (0)