Skip to content

Commit

Permalink
Merge pull request #8 from ecency/bugfix/review-issues-2
Browse files Browse the repository at this point in the history
Bugfix/review issues 2
  • Loading branch information
feruzm authored Sep 9, 2024
2 parents 2118b8c + 6c64845 commit 829654a
Show file tree
Hide file tree
Showing 30 changed files with 420 additions and 278 deletions.
153 changes: 79 additions & 74 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const config = {
return config;
},
images: {
unoptimized: true,
remotePatterns: [
{
protocol: "https",
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
"test": "jest"
},
"dependencies": {
"@bugsnag/browser-performance": "^2.9.0",
"@bugsnag/js": "^8.0.0",
"@bugsnag/plugin-react": "^8.0.0",
"@ecency/ns-query": "1.2.9-next",
"@ecency/render-helper": "^2.2.29",
"@emoji-mart/data": "^1.1.2",
Expand Down
1 change: 1 addition & 0 deletions public/sw.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions public/workbox-9b4d2a02.js

Large diffs are not rendered by default.

42 changes: 37 additions & 5 deletions src/api/mutations/entry-reblog.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import { useMutation } from "@tanstack/react-query";
import { Entry } from "@/entities";
import { useMutation, useQueryClient } from "@tanstack/react-query";
import { BlogEntry, Entry } from "@/entities";
import { broadcastPostingJSON, formatError } from "@/api/operations";
import { useGlobalStore } from "@/core/global-store";
import { useRecordUserActivity } from "@/api/mutations/record-user-activity";
import { error, info, success } from "@/features/shared";
import i18next from "i18next";
import { QueryIdentifiers } from "@/core/react-query";
import { EcencyEntriesCacheManagement } from "@/core/caches";

export function useEntryReblog(entry: Entry) {
const activeUser = useGlobalStore((s) => s.activeUser);
const { mutateAsync: recordUserActivity } = useRecordUserActivity();
const queryClient = useQueryClient();

return useMutation({
mutationKey: ["entryReblog", activeUser?.username, entry.author, entry.permlink],
Expand All @@ -26,13 +29,42 @@ export function useEntryReblog(entry: Entry) {

const json = ["reblog", message];
const r = await broadcastPostingJSON(username, "follow", json);
await recordUserActivity({ ty: 130, bl: r.block_num, tx: r.id });
recordUserActivity({ ty: 130, bl: r.block_num, tx: r.id });
return [r, isDelete];
},
onSuccess: ([_, isDelete]) =>
onSuccess: ([_, isDelete]) => {
isDelete
? info(i18next.t("entry-reblog.delete-success"))
: success(i18next.t("entry-reblog.success")),
: success(i18next.t("entry-reblog.success"));
EcencyEntriesCacheManagement.updateReblogsCount(
entry,
(entry.reblogs ?? 0) + (isDelete ? -1 : 1)
);
queryClient.setQueryData<BlogEntry[]>(
[QueryIdentifiers.REBLOGS, activeUser?.username, 200],
(data) => {
if (!data) {
return data;
}

return isDelete
? data.filter((d) => d.author !== entry.author || d.permlink !== entry.permlink)
: [
{
entry_id: entry.id ?? 0,
blog: activeUser?.username ?? "",
post_id: entry.post_id,
num: 0,
author: entry.author,
permlink: entry.permlink,
reblogged_on: new Date().toISOString(),
created: entry.created
},
...data
];
}
);
},
onError: (e) => error(...formatError(e))
});
}
8 changes: 6 additions & 2 deletions src/api/mutations/notifications/mark-notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@ export function useMarkNotifications() {
return useMutation({
mutationKey: ["notifications", "mark"],
mutationFn: ({ id }: { id: string | undefined }) => markNotifications(activeUser!.username, id),
onSuccess: () =>
onSuccess: () => {
queryClient.invalidateQueries({
queryKey: [QueryIdentifiers.NOTIFICATIONS_UNREAD_COUNT, activeUser?.username]
})
});
queryClient.invalidateQueries({
queryKey: [QueryIdentifiers.NOTIFICATIONS, activeUser?.username]
});
}
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export function useUpdateNotificationsSettings() {
),
onError: (e) => error(...formatError(e)),
onSuccess: (settings) => {
console.log("here", settings);
success(i18next.t("preferences.updated"));
getQueryClient().setQueryData(
[QueryIdentifiers.NOTIFICATIONS_SETTINGS, activeUser?.username],
Expand Down
17 changes: 2 additions & 15 deletions src/api/queries/dynamic-props-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export const getDynamicPropsQuery = () =>
EcencyQueriesManager.generateClientServerQuery({
queryKey: [QueryIdentifiers.DYNAMIC_PROPS],
refetchInterval: 60000,
staleTime: 60000,
refetchOnMount: true,
queryFn: async (): Promise<DynamicProps> => {
const globalDynamic = await getDynamicGlobalProperties();
const feedHistory = await getFeedHistory();
Expand Down Expand Up @@ -50,20 +52,5 @@ export const getDynamicPropsQuery = () =>
vestingRewardPercent,
accountCreationFee
};
},
initialData: {
hivePerMVests: 1,
base: 1,
quote: 1,
fundRecentClaims: 1,
fundRewardBalance: 1,
hbdPrintRate: 1,
hbdInterestRate: 1,
headBlock: 1,
totalVestingFund: 1,
totalVestingShares: 1,
virtualSupply: 1,
vestingRewardPercent: 1,
accountCreationFee: "3.000 HIVE"
}
});
Loading

0 comments on commit 829654a

Please sign in to comment.