HomePhabricator
Diffusion Comm 47b7cf30a23a

[Flow202][keyserver][skip-ci] [21/x] Make Date subtraction explicit

Description

[Flow202][keyserver][skip-ci] [21/x] Make Date subtraction explicit

Summary:
The new version of Flow was printing these errors:

Error ------------------------------------------------------------------------------------- src/utils/olm-utils.js:50:10

Cannot use operator `-` with operands Date [1] and Date [2] [unsafe-arithmetic]

 [2] 31| function getLastPrekeyPublishTime(account: OlmAccount): Date {
       :
 [1] 47|   const currentDate = new Date();
     48|   const lastPrekeyPublishDate = getLastPrekeyPublishTime(account);
     49|
     50|   return currentDate - lastPrekeyPublishDate >= maxPublishedPrekeyAge;
     51| }
     52|
     53| function shouldForgetPrekey(account: OlmAccount): boolean {

Looks like they just want us to a bit more explicit, so I added the getTime() call. I got that approach from this similar discussion on the TypeScript repo.

NOTE: CI will fail on this diff. I considered the possibility of fixing Flow errors BEFORE upgrading Flow, but it wasn't possible... in some cases, the fixes to support the new version of Flow caused errors in the old version. I could have hidden these type errors with $FlowFixMe lines and then later revert those, but that seemed like too much busy work.

Depends on D9869

Test Plan: Confirm the Flow errors go away

Reviewers: tomek

Reviewed By: tomek

Differential Revision: https://phab.comm.dev/D9870

Details