File tree Expand file tree Collapse file tree 3 files changed +23
-17
lines changed
Expand file tree Collapse file tree 3 files changed +23
-17
lines changed Original file line number Diff line number Diff line change 1- import { FunctionComponent } from 'preact' ;
1+ import type { FunctionComponent } from 'preact' ;
2+ import { useCallback } from 'preact/compat' ;
23import type { Point } from 'geojson' ;
34import Icon from '../Icon' ;
45import { formatCoord } from '../util' ;
@@ -14,16 +15,13 @@ const PositionCell: FunctionComponent<Props> = ({ coord }) => {
1415 query : [ coord . coordinates [ 1 ] , coord . coordinates [ 0 ] ] . join ( ',' ) ,
1516 } ) ;
1617 const url = 'https://www.google.com/maps/search/?' + params . toString ( ) ;
18+ const onCopyClick = useCallback ( ( ) => {
19+ navigator . clipboard . writeText ( stringCoord ) . catch ( console . error ) ;
20+ } , [ stringCoord ] ) ;
1721 return (
1822 < td className = "position" >
1923 < a href = { url } > { stringCoord } </ a >
20- < Icon
21- name = "copy"
22- label = "Copy coordinates"
23- onClick = { ( ) => {
24- navigator . clipboard . writeText ( stringCoord ) . catch ( console . error ) ;
25- } }
26- />
24+ < Icon name = "copy" label = "Copy coordinates" onClick = { onCopyClick } />
2725 </ td >
2826 ) ;
2927} ;
Original file line number Diff line number Diff line change 11import { FunctionComponent } from 'preact' ;
2- import { useMemo } from 'preact/compat' ;
32import { decorate } from '../computation' ;
43import { selectExtraGc , selectGameConfig } from '../gameConfig' ;
5- import { useAppSelector } from '../store' ;
4+ import { createAppSelector , useAppSelector } from '../store' ;
65import Grid from './Grid' ;
76
8- const Results : FunctionComponent = ( ) => {
9- const game = useAppSelector ( selectGameConfig ) ;
10- const extraGc = useAppSelector ( selectExtraGc ) ;
11- const photos = useAppSelector ( ( state ) => state . data . photos ) ;
12- const results = useMemo ( ( ) => {
7+ const selectResults = createAppSelector (
8+ [ selectGameConfig , ( state ) => state . data . photos ] ,
9+ ( game , photos ) => {
1310 if ( game && photos && photos . features . length > 0 ) {
1411 return decorate ( game , photos ) ;
1512 } else {
1613 return null ;
1714 }
18- } , [ game , photos ] ) ;
15+ }
16+ ) ;
17+
18+ const Results : FunctionComponent = ( ) => {
19+ const extraGc = useAppSelector ( selectExtraGc ) ;
20+ const results = useAppSelector ( selectResults ) ;
1921 if ( results && results . features . length > 0 ) {
2022 return (
2123 < >
Original file line number Diff line number Diff line change @@ -14,7 +14,13 @@ import { kml } from './togeojson';
1414const readFile = ( f : Blob ) : Promise < string > =>
1515 new Promise ( ( resolve , reject ) => {
1616 const reader = new FileReader ( ) ;
17- reader . addEventListener ( 'load' , ( ) => resolve ( reader . result as string ) ) ;
17+ reader . addEventListener ( 'load' , ( ) => {
18+ if ( typeof reader . result === 'string' ) {
19+ resolve ( reader . result ) ;
20+ } else {
21+ reject ( 'Could not read data' ) ;
22+ }
23+ } ) ;
1824 reader . addEventListener ( 'error' , ( e ) => reject ( 'Could not read file' ) ) ;
1925 reader . readAsText ( f ) ;
2026 } ) ;
You can’t perform that action at this time.
0 commit comments