File tree Expand file tree Collapse file tree 7 files changed +25
-13
lines changed
Expand file tree Collapse file tree 7 files changed +25
-13
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,10 @@ import { getSelectedPage } from '../../state/selectors/workpad';
2121
2222const reload$ = new Subject < void > ( ) ;
2323
24+ export function forceReload ( ) {
25+ reload$ . next ( ) ;
26+ }
27+
2428export const useCanvasApi : ( ) => CanvasContainerApi = ( ) => {
2529 const selectedPageId = useSelector ( getSelectedPage ) ;
2630 const dispatch = useDispatch ( ) ;
@@ -41,9 +45,6 @@ export const useCanvasApi: () => CanvasContainerApi = () => {
4145 const getCanvasApi = useCallback ( ( ) : CanvasContainerApi => {
4246 return {
4347 reload$,
44- reload : ( ) => {
45- reload$ . next ( ) ;
46- } ,
4748 viewMode : new BehaviorSubject < ViewMode > ( 'edit' ) , // always in edit mode
4849 addNewPanel : async ( {
4950 panelType,
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ import React from 'react';
99import { Shortcuts } from 'react-shortcuts' ;
1010import { isTextInput } from '../../lib/is_text_input' ;
1111import { Props } from './workpad.component' ;
12+ import { forceReload } from '../hooks/use_canvas_api' ;
1213
1314type ShortcutProps = Pick <
1415 Props ,
@@ -69,7 +70,10 @@ export class WorkpadShortcuts extends React.Component<ShortcutProps> {
6970
7071 // handle keypress events for editor events
7172 _keyMap : Shortcuts = {
72- REFRESH : this . props . fetchAllRenderables ,
73+ REFRESH : ( ) => {
74+ forceReload ( ) ;
75+ this . props . fetchAllRenderables ( ) ;
76+ } ,
7377 UNDO : this . props . undoHistory ,
7478 REDO : this . props . redoHistory ,
7579 GRID : ( ) => this . props . setGrid ( ! this . props . grid ) ,
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import PropTypes from 'prop-types';
1010// @ts -expect-error no @types definition
1111import { Shortcuts } from 'react-shortcuts' ;
1212import { isTextInput } from '../../../lib/is_text_input' ;
13+ import { forceReload } from '../../hooks/use_canvas_api' ;
1314
1415interface ChildrenProps {
1516 isFullscreen : boolean ;
@@ -64,7 +65,10 @@ export class FullscreenControl extends React.PureComponent<Props> {
6465
6566 // handle keypress events for presentation events
6667 _keyMap : { [ key : string ] : ( ...args : any [ ] ) => void } = {
67- REFRESH : this . props . fetchAllRenderables ,
68+ REFRESH : ( ) => {
69+ forceReload ( ) ;
70+ this . props . fetchAllRenderables ( ) ;
71+ } ,
6872 PREV : this . previousPage ,
6973 NEXT : this . nextPage ,
7074 FULLSCREEN : this . _toggleFullscreen ,
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ import { useDispatch, useSelector } from 'react-redux';
1515import { fetchAllRenderables } from '../../../state/actions/elements' ;
1616import { getInFlight } from '../../../state/selectors/resolved_args' ;
1717import { ToolTipShortcut } from '../../tool_tip_shortcut' ;
18- import { useCanvasApi } from '../../hooks/use_canvas_api' ;
18+ import { forceReload } from '../../hooks/use_canvas_api' ;
1919
2020const strings = {
2121 getRefreshAriaLabel : ( ) =>
@@ -31,11 +31,10 @@ const strings = {
3131export const RefreshControl = ( ) => {
3232 const dispatch = useDispatch ( ) ;
3333 const inFlight = useSelector ( getInFlight ) ;
34- const canvasApi = useCanvasApi ( ) ;
3534 const doRefresh = useCallback ( ( ) => {
36- canvasApi . reload ( ) ;
35+ forceReload ( ) ;
3736 dispatch ( fetchAllRenderables ( ) ) ;
38- } , [ canvasApi , dispatch ] ) ;
37+ } , [ dispatch ] ) ;
3938
4039 return (
4140 < EuiToolTip
Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ import {
2525import { WorkpadRoutingContext } from '../../../routes/workpad' ;
2626import { ViewMenu as Component , Props as ComponentProps } from './view_menu.component' ;
2727import { getFitZoomScale } from './lib/get_fit_zoom_scale' ;
28+ import { forceReload } from '../../hooks/use_canvas_api' ;
2829
2930interface StateProps {
3031 zoomScale : number ;
@@ -61,7 +62,10 @@ const mapStateToProps = (state: State) => {
6162const mapDispatchToProps = ( dispatch : Dispatch ) => ( {
6263 setZoomScale : ( scale : number ) => dispatch ( setZoomScale ( scale ) ) ,
6364 setWriteable : ( isWorkpadWriteable : boolean ) => dispatch ( setWriteable ( isWorkpadWriteable ) ) ,
64- doRefresh : ( ) => dispatch ( fetchAllRenderables ( ) ) ,
65+ doRefresh : ( ) => {
66+ forceReload ( ) ;
67+ dispatch ( fetchAllRenderables ( ) ) ;
68+ } ,
6569} ) ;
6670
6771const mergeProps = (
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import { WorkpadRoutingContext } from '../workpad_routing_context';
1111import { getInFlight } from '../../../state/selectors/resolved_args' ;
1212// @ts -expect-error untyped local
1313import { fetchAllRenderables } from '../../../state/actions/elements' ;
14+ import { forceReload } from '../../../components/hooks/use_canvas_api' ;
1415
1516export const useRefreshHelper = ( ) => {
1617 const dispatch = useDispatch ( ) ;
@@ -25,6 +26,7 @@ export const useRefreshHelper = () => {
2526
2627 if ( refreshInterval > 0 && ! inFlight ) {
2728 timer . current = window . setTimeout ( ( ) => {
29+ forceReload ( ) ;
2830 dispatch ( fetchAllRenderables ( ) ) ;
2931 } , refreshInterval ) ;
3032 }
Original file line number Diff line number Diff line change @@ -30,6 +30,4 @@ export type CanvasContainerApi = PublishesViewMode &
3030 HasType &
3131 HasSerializedChildState &
3232 PublishesReload &
33- Partial < HasAppContext & PublishesUnifiedSearch > & {
34- reload : ( ) => void ;
35- } ;
33+ Partial < HasAppContext & PublishesUnifiedSearch > ;
You can’t perform that action at this time.
0 commit comments