Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add offline service #874

Merged
merged 50 commits into from
Aug 31, 2021
Merged

feat: add offline service #874

merged 50 commits into from
Aug 31, 2021

Conversation

KaiVandivier
Copy link
Contributor

@KaiVandivier KaiVandivier commented Jun 9, 2021

Adds an <OfflineProvider> component that serves a <CacheableSection> component, a useCacheableSection hook, and useCachedSection(s) hook(s) as a part of Dashboard as a Progressive Web App. Also include a useOnlineStatus hook.

To do after alpha release:

  • Make sure the links to the platform documentation from the docs here are correct
  • Refactor state management to reduce rerenders of all context consumers, a la globalStateService
  • Convert to typescript (and reinstate strict settings in tsconfig.json)
  • Reexport offline-service modules from runtime package

@KaiVandivier KaiVandivier changed the base branch from master to alpha June 14, 2021 09:41
@KaiVandivier KaiVandivier requested review from amcgee and mediremi June 14, 2021 09:43
Copy link
Contributor

@mediremi mediremi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM ✔️ my only feedback is I think useOnlineStatus should use lodash.debounce instead of lodash.throttle (and the associated tests should be updated too).


## Installation

This package is internal to `@dhis2/app-runtime` and generally should not be installed independently.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(This is not true yet - will be true once released and reexported from the app-runtime package)

@@ -0,0 +1,11 @@
module.exports = {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is copied/pasted from other services packages

@@ -0,0 +1,22 @@
import { render } from '@testing-library/react'
Copy link
Contributor Author

@KaiVandivier KaiVandivier Jun 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit of a placeholder; currently just the offlineInterface initialization is tested. More to come in the future

Comment on lines 1 to 3
export { OfflineProvider } from './lib/offline-provider'
export { CacheableSection, useCacheableSection } from './lib/cacheable-section'
export { useOnlineStatus } from './lib/online-status'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is OK for now, we can add an export of useCachedSections in the future if we need it

import React from 'react'

// eslint-disable-next-line react/prop-types
export const RenderCounter = ({ id, countsObj }) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this only used for tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that's right

@KaiVandivier KaiVandivier changed the base branch from alpha to master July 21, 2021 13:03
@KaiVandivier KaiVandivier changed the base branch from master to alpha July 21, 2021 14:00
@KaiVandivier KaiVandivier changed the base branch from alpha to master July 21, 2021 16:39
amcgee and others added 11 commits July 21, 2021 19:03
* chore: add tsconfig and set up package.json

* refactor: convert online-status to TS

* refactor: convert index and setupRTL to TS

* chore: switch entry point to index.ts

* refactor: add types to offline-provider

* refactor: move shared types to own file

* refactor: add types to offline interface

* refactor: add types to global state service

* chore: update path to RTL setup

* refactor: add types to cacheable section

* refactor: recording state type

* refactor: make sure offlineInterface is never null

* refactor: global state mutation types

* refactor: add types to cacheable section state

* refactor: offline provider return value

* refactor(offline-provider): make children optional

* refactor: offline-provider test to typescript

* refactor: make options optional

* refactor: convert to typescript

* refactor: convert to typescript

* refactor: convert to typescript

* refactor: convert to typescript

* refactor: use stricter TS settings

* chore: specify milliseconds in debounceDelay type
…ction (#946)

* fix: allow useCS hook to be used in child of CS component

* refactor: also remove recording state on unmount if 'error'

* refactor: make conditions clearer
@KaiVandivier KaiVandivier merged commit 578bd41 into master Aug 31, 2021
@KaiVandivier KaiVandivier deleted the feat-add-offline-service branch August 31, 2021 11:46
dhis2-bot added a commit that referenced this pull request Aug 31, 2021
# [2.11.0](v2.10.0...v2.11.0) (2021-08-31)

### Features

* add offline service ([#874](#874)) ([578bd41](578bd41))
@dhis2-bot
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants