@@ -119,6 +119,10 @@ import { SummarizedNotificationState } from "../../stores/notifications/Summariz
119
119
import GenericToast from '../views/toasts/GenericToast' ;
120
120
import Views from '../../Views' ;
121
121
import { ViewRoomPayload } from "../../dispatcher/payloads/ViewRoomPayload" ;
122
+ import { ViewHomePagePayload } from '../../dispatcher/payloads/ViewHomePagePayload' ;
123
+ import { AfterLeaveRoomPayload } from '../../dispatcher/payloads/AfterLeaveRoomPayload' ;
124
+ import { DoAfterSyncPreparedPayload } from '../../dispatcher/payloads/DoAfterSyncPreparedPayload' ;
125
+ import { ViewStartChatOrReusePayload } from '../../dispatcher/payloads/ViewStartChatOrReusePayload' ;
122
126
123
127
// legacy export
124
128
export { default as Views } from "../../Views" ;
@@ -541,7 +545,7 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
541
545
// will cause a full login and sync and finally the deferred
542
546
// action will be dispatched.
543
547
dis . dispatch ( {
544
- action : 'do_after_sync_prepared' ,
548
+ action : Action . DoAfterSyncPrepared ,
545
549
deferred_action : payload ,
546
550
} ) ;
547
551
dis . dispatch ( { action : 'require_registration' } ) ;
@@ -632,7 +636,7 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
632
636
MatrixClientPeg . get ( ) . leave ( payload . room_id ) . then ( ( ) => {
633
637
modal . close ( ) ;
634
638
if ( this . state . currentRoomId === payload . room_id ) {
635
- dis . dispatch ( { action : 'view_home_page' } ) ;
639
+ dis . dispatch ( { action : Action . ViewHomePage } ) ;
636
640
}
637
641
} , ( err ) => {
638
642
modal . close ( ) ;
@@ -705,10 +709,10 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
705
709
case 'view_welcome_page' :
706
710
this . viewWelcome ( ) ;
707
711
break ;
708
- case 'view_home_page' :
712
+ case Action . ViewHomePage :
709
713
this . viewHome ( payload . justRegistered ) ;
710
714
break ;
711
- case 'view_start_chat_or_reuse' :
715
+ case Action . ViewStartChatOrReuse :
712
716
this . chatCreateOrReuse ( payload . user_id ) ;
713
717
break ;
714
718
case 'view_create_chat' :
@@ -1057,10 +1061,10 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
1057
1061
// No point in making 2 DMs with welcome bot. This assumes view_set_mxid will
1058
1062
// result in a new DM with the welcome user.
1059
1063
if ( userId !== this . props . config . welcomeUserId ) {
1060
- dis . dispatch ( {
1061
- action : 'do_after_sync_prepared' ,
1064
+ dis . dispatch < DoAfterSyncPreparedPayload < ViewStartChatOrReusePayload > > ( {
1065
+ action : Action . DoAfterSyncPrepared ,
1062
1066
deferred_action : {
1063
- action : 'view_start_chat_or_reuse' ,
1067
+ action : Action . ViewStartChatOrReuse ,
1064
1068
user_id : userId ,
1065
1069
} ,
1066
1070
} ) ;
@@ -1162,8 +1166,8 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
1162
1166
if ( shouldLeave ) {
1163
1167
leaveRoomBehaviour ( roomId ) ;
1164
1168
1165
- dis . dispatch ( {
1166
- action : "after_leave_room" ,
1169
+ dis . dispatch < AfterLeaveRoomPayload > ( {
1170
+ action : Action . AfterLeaveRoom ,
1167
1171
room_id : roomId ,
1168
1172
} ) ;
1169
1173
}
@@ -1176,7 +1180,7 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
1176
1180
MatrixClientPeg . get ( ) . forget ( roomId ) . then ( ( ) => {
1177
1181
// Switch to home page if we're currently viewing the forgotten room
1178
1182
if ( this . state . currentRoomId === roomId ) {
1179
- dis . dispatch ( { action : "view_home_page" } ) ;
1183
+ dis . dispatch ( { action : Action . ViewHomePage } ) ;
1180
1184
}
1181
1185
1182
1186
// We have to manually update the room list because the forgotten room will not
@@ -1275,7 +1279,7 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
1275
1279
if ( welcomeUserRoom === null ) {
1276
1280
// We didn't redirect to the welcome user room, so show
1277
1281
// the homepage.
1278
- dis . dispatch ( { action : 'view_home_page' , justRegistered : true } ) ;
1282
+ dis . dispatch < ViewHomePagePayload > ( { action : Action . ViewHomePage , justRegistered : true } ) ;
1279
1283
}
1280
1284
} else if ( ThreepidInviteStore . instance . pickBestInvite ( ) ) {
1281
1285
// The user has a 3pid invite pending - show them that
@@ -1288,7 +1292,7 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
1288
1292
} else {
1289
1293
// The user has just logged in after registering,
1290
1294
// so show the homepage.
1291
- dis . dispatch ( { action : 'view_home_page' , justRegistered : true } ) ;
1295
+ dis . dispatch < ViewHomePagePayload > ( { action : Action . ViewHomePage , justRegistered : true } ) ;
1292
1296
}
1293
1297
} else {
1294
1298
this . showScreenAfterLogin ( ) ;
@@ -1353,7 +1357,7 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
1353
1357
if ( MatrixClientPeg . get ( ) . isGuest ( ) ) {
1354
1358
dis . dispatch ( { action : 'view_welcome_page' } ) ;
1355
1359
} else {
1356
- dis . dispatch ( { action : 'view_home_page' } ) ;
1360
+ dis . dispatch ( { action : Action . ViewHomePage } ) ;
1357
1361
}
1358
1362
}
1359
1363
}
@@ -1666,7 +1670,7 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
1666
1670
const isLoggedOutOrGuest = ! cli || cli . isGuest ( ) ;
1667
1671
if ( ! isLoggedOutOrGuest && AUTH_SCREENS . includes ( screen ) ) {
1668
1672
// user is logged in and landing on an auth page which will uproot their session, redirect them home instead
1669
- dis . dispatch ( { action : "view_home_page" } ) ;
1673
+ dis . dispatch ( { action : Action . ViewHomePage } ) ;
1670
1674
return ;
1671
1675
}
1672
1676
@@ -1714,7 +1718,7 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
1714
1718
} ) ;
1715
1719
} else if ( screen === 'home' ) {
1716
1720
dis . dispatch ( {
1717
- action : 'view_home_page' ,
1721
+ action : Action . ViewHomePage ,
1718
1722
} ) ;
1719
1723
} else if ( screen === 'start' ) {
1720
1724
this . showScreen ( 'home' ) ;
@@ -1737,7 +1741,7 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
1737
1741
PlatformPeg . get ( ) . startSingleSignOn ( cli , type , this . getFragmentAfterLogin ( ) ) ;
1738
1742
} else if ( screen === 'groups' ) {
1739
1743
if ( SpaceStore . spacesEnabled ) {
1740
- dis . dispatch ( { action : "view_home_page" } ) ;
1744
+ dis . dispatch ( { action : Action . ViewHomePage } ) ;
1741
1745
return ;
1742
1746
}
1743
1747
dis . dispatch ( {
0 commit comments