Skip to content
This repository has been archived by the owner on Nov 3, 2020. It is now read-only.

Setup error screens #1050

Merged
merged 2 commits into from Jan 16, 2020
Merged

Setup error screens #1050

merged 2 commits into from Jan 16, 2020

Conversation

beausmith
Copy link
Contributor

@beausmith beausmith commented Jan 9, 2020

Fixes #1041

This PR needs:

  • backend data to enable screens.
  • tests based upon mocked data.

Error Screens

These screens will display for all users if the state is such.

Low battery and no charger

image

Card Reader not detected

image

No Printer Detected

image

Printer Error Detected

image

Warnings on Insert Card Screen

These warnings are informational but non-blocking. They are visible to both Poll Workers and Voters.

Note: It is possible for both of these warnings to appear at the same time.

No Power Warning

image

No Accessible Controller Warning

image

@netlify
Copy link

netlify bot commented Jan 9, 2020

Deploy preview for vw-bmd ready!

Built with commit 8d293b3

https://deploy-preview-1050--vw-bmd.netlify.com

@beausmith beausmith force-pushed the setup-error-screens branch 2 times, most recently from 92765ca to 41ebda4 Compare January 9, 2020 07:12
src/AppRoot.tsx Show resolved Hide resolved
src/AppRoot.tsx Outdated Show resolved Hide resolved
@beausmith
Copy link
Contributor Author

beausmith commented Jan 10, 2020

@eventualbuddha - I have added a Hardware API. This seemed simpler than separate APIs for each.

Open to all suggestions for any refactors, etc.

What else do you need from me to implement a "module-hardware" or whatever you think is best?

I'm adding tests now…

AcessibleControllerAPI
> {
console.log("Why is 'this' undefined?", this)
return this.accessibleControllerStatus
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@eventualbuddha - The last commit on this branch is a WIP with debugging code. I'm stumped as to why this is undefined. MemoryHardware is modeled after the MemoryCard, but something must be different. Do you see where the error in this code is?

Copy link
Contributor

Choose a reason for hiding this comment

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

Commented at the source of the problem. It’s an unbound method problem. I’d fix it by doing const { hardware } = this.props and calling i.e. await hardware.read….

src/App.tsx Outdated Show resolved Hide resolved
src/AppRoot.tsx Outdated
readCardReaderStatus,
readPrinterStatus,
} = this.props.hardware
const accesssibleController = await readAccesssibleControllerStatus()
Copy link
Contributor

Choose a reason for hiding this comment

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

This is the call that’s making this be undefined inside readAccesssibleControllerStatus. When you call a function without a context in strict mode you get this === undefined (in non-strict mode you get this === window).

For example:

const obj = { m() { return this } }
const { m } = obj
const mBound = ::obj.m // https://github.com/tc39/proposal-bind-operator

// These all pass.
assert(obj.m() === obj)
assert(m() === undefined)
assert(m.call(obj) === obj)
assert(mBound() === obj)

Note that the bind operator proposal is still stage 0 and won’t be implemented in TS until stage 3 at the earliest.

/**
* Sets Battery level. Number between 0–1.
*/
setBatteryLevel(level: number): Promise<void>
Copy link
Contributor

Choose a reason for hiding this comment

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

These set* methods don’t represent operations we can actually perform in non-test scenarios, i.e. the battery level is what it is. I’d say these should not be present on the Hardware interface but should be defined on MemoryHardware. Unless I’m missing something?

AcessibleControllerAPI
> {
console.log("Why is 'this' undefined?", this)
return this.accessibleControllerStatus
Copy link
Contributor

Choose a reason for hiding this comment

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

Commented at the source of the problem. It’s an unbound method problem. I’d fix it by doing const { hardware } = this.props and calling i.e. await hardware.read….

@beausmith
Copy link
Contributor Author

@eventualbuddha - I've rebased, squashed, and pushed commits. Everything is working, however there are a couple regressions I've failed to figure out. I've got to hang my hat for the night. Back to this tomorrow.

@beausmith beausmith force-pushed the setup-error-screens branch 2 times, most recently from 9d819e2 to dfca446 Compare January 16, 2020 19:29
@beausmith beausmith marked this pull request as ready for review January 16, 2020 21:19
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hardware Setup Error Screens and Warning Messages
2 participants