• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

kobotoolbox / kpi / 12055670534
82%
master: 76%

Build:
Build:
LAST BUILD BRANCH: fix-and-consolidate-submission-version-matching
DEFAULT BRANCH: master
Ran 27 Nov 2024 06:22PM UTC
Jobs 1
Files 608
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

27 Nov 2024 05:46PM UTC coverage: 80.096%. Remained the same
12055670534

push

github

web-flow
refactor(organizations): add of useSession hook TASK-1305  (#5303)

### 👀 Preview steps
No behavior will change with this implementation, but it can be tested
by using the new hook somewhere.
As a test I've modified `MyProjectRoute` to verify that
`currentLoggedAccount` was properly dispatching component re-render and
that using hooks methods are working properly as well:
```typescript
...
export default function MyProjectsRoute() {

  const [counter, setCounter] = React.useState(0);

  const {currentLoggedAccount, refreshAccount} = useSession();

  useEffect(() => {
    setCounter((prev) => prev + 1);
  }, [currentLoggedAccount]);

  return (
    <>
    <button onClick={refreshAccount}>Refresh {counter} - {currentLoggedAccount?.username}</button>
    <UniversalProjectsRoute
...
```
Result:

![KPI_5303](https://github.com/user-attachments/assets/be5f9c7f-ce37-459b-90a7-9848bb88db7d)

### 💭 Notes

- This PR adds the `useSession` hook, aimed to be used instead of the
current `sessionStore` class to access the session data and methods.
- The `useSession` hook returns the `currentLoggedAccount` user, which
is already filtered to be an existent account returned from the `/me`
endpoint and verified not to be an anonymous account, which is currently
done in several places around the codebase where the `currentAccount`
from `sessionStore` is used.
- The internal implementation of this hook will eventually migrate to
use `react-query`, keeping the hook's signature.
- This implementation can be used as a base for the migration of the
other existing stores to allow for future dropping of `mob-x` in favor
of using react-query to cache data.
- First usage of this hook can be seen in
https://github.com/kobotoolbox/kpi/pull/5290

5643 of 9109 branches covered (61.95%)

21606 of 26975 relevant lines covered (80.1%)

0.8 hits per line

Jobs
ID Job ID Ran Files Coverage
1 12055670534.1 27 Nov 2024 06:22PM UTC 0
80.1
Source Files on build 12055670534
Detailed source file information is not available for this build.
  • Back to Repo
  • b8184e8f on github
  • Prev Build on main (#12052745069)
  • Next Build on main (#12058806879)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc