Skip to content

Commit

Permalink
fix(refresh): added refresh interval to indexer
Browse files Browse the repository at this point in the history
  • Loading branch information
bitbeckers committed Oct 1, 2023
1 parent 8ddd734 commit cbd6ca6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 18 deletions.
20 changes: 4 additions & 16 deletions src/components/HistoryCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ const DootBox = styled.div`
export const HistoryCard = ({ record }: { record: Cookie }) => {
const { chainId } = useDHConnect();
const { fireTransaction } = useTxBuilder();
const [reason, setReason] = useState<Reason>();
const { profile: cookieGiver } = useProfile({
address: record.cookieGiver,
});
Expand All @@ -45,26 +44,15 @@ export const HistoryCard = ({ record }: { record: Cookie }) => {
[record]
);

console.log("record: ", record);

const doots = useLiveQuery(
() => db.ratings.where({ assessTag: record.assessTag }).toArray(),
[record]
);

useEffect(() => {
const fetchReason = async () => {
console.log("Fetching reason: ", record.reasonTag);
const res = await db.reasons.get({ reasonTag: record.reasonTag });
if (!res) {
return;
}
console.log("Reason: ", res);
setReason(res);
};

fetchReason();
}, [record.reasonTag]);
const reason = useLiveQuery(
() => db.reasons.get({ reasonTag: record.reasonTag }),
[record]
);

const onDoot = async (doot: "up" | "down") => {
if (!cookieJar?.address) {
Expand Down
4 changes: 2 additions & 2 deletions src/utils/indexer/CookieJarIndexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { PublicClient, decodeEventLog } from "viem";
import { db, CookieDB } from "./db";
import { AbiEvent, parseAbi, parseAbiItem } from "abitype";
import { EventHandlers, getEventHandler } from "./eventHandlers";
import { debounce } from "lodash";
import { debounce, set } from "lodash";
import { postHandler } from "./posterHandlers";

interface CookieJarIndexerInterface {
Expand All @@ -28,7 +28,7 @@ class CookieJarIndexer implements CookieJarIndexerInterface {
this.update = debounce(async () => this._update(), 5000, {
maxWait: 60000,
});
this.update();
setInterval(this.update, 10000);
}

public get db() {
Expand Down

0 comments on commit cbd6ca6

Please sign in to comment.