Skip to content

Commit

Permalink
Add a refresh button (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
pvcnt authored May 19, 2024
1 parent 6c4d598 commit 1e185e0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,10 @@ module.exports = {
{ allowConstantExport: true },
],
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-misused-promises': [
'error',
// https://github.com/typescript-eslint/typescript-eslint/issues/4619
{ checksVoidReturn: false }
],
},
}
13 changes: 12 additions & 1 deletion src/routes/dashboard.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useContext, useEffect, useState } from "react";
import { useCallback, useContext, useEffect, useState } from "react";
import { Section, emptySectionConfig, ConfigContext } from "../config";
import DashboardSection from "../components/DashboardSection";
import { Button, InputGroup } from "@blueprintjs/core";
Expand Down Expand Up @@ -39,6 +39,12 @@ export default function Dashboard() {
}),
})

const refetchAll = useCallback(async () => {
await Promise.all(results.map(res => res.refetch()));
}, [results]);

const isFetching = results.some(res => res.isFetching)

const tokens = search.split(" ").map(tok => tok.toLowerCase())

const count = sum(config.sections.map((section, idx) => {
Expand Down Expand Up @@ -77,6 +83,11 @@ export default function Dashboard() {
<div className="flex w-full">
<InputGroup leftIcon="search" placeholder="Search pull requests" round className="grow" value={search} onChange={e => setSearch(e.target.value)} />
<Button text="New section" icon="plus" onClick={() => setEditing(true)} className="ml-4"/>
<Button icon="refresh"
disabled={isFetching}
loading={isFetching}
className="ml-4"
onClick={refetchAll}/>
</div>
<SectionDialog
section={emptySectionConfig}
Expand Down

0 comments on commit 1e185e0

Please sign in to comment.