@@ -19,6 +19,7 @@ limitations under the License.
19
19
20
20
import * as React from 'react' ;
21
21
import { User } from "matrix-js-sdk/src/models/user" ;
22
+ import { Direction } from 'matrix-js-sdk/src/models/event-timeline' ;
22
23
import { EventType } from "matrix-js-sdk/src/@types/event" ;
23
24
import * as ContentHelpers from 'matrix-js-sdk/src/content-helpers' ;
24
25
import { parseFragment as parseHtml , Element as ChildElement } from "parse5" ;
@@ -286,6 +287,38 @@ export const Commands = [
286
287
category : CommandCategories . admin ,
287
288
renderingTypes : [ TimelineRenderingType . Room ] ,
288
289
} ) ,
290
+ new Command ( {
291
+ command : 'jumptodate' ,
292
+ args : '<date>' ,
293
+ description : _td ( 'Jump to the given date in the timeline' ) ,
294
+ runFn : function ( roomId , args ) {
295
+ if ( args ) {
296
+ return success ( ( async ( ) => {
297
+ const unixTimestamp = Date . parse ( args ) ;
298
+ if ( ! unixTimestamp ) {
299
+ throw new Error ( `Unable to parse given date ${ args } ` ) ;
300
+ }
301
+
302
+ const cli = MatrixClientPeg . get ( ) ;
303
+ const { event_id, origin_server_ts } = await cli . timestampToEvent (
304
+ roomId ,
305
+ unixTimestamp ,
306
+ Direction . Forward ,
307
+ )
308
+ logger . log ( `/timestamp_to_event: found ${ event_id } (${ origin_server_ts } ) for timestamp=${ unixTimestamp } ` ) ;
309
+ dis . dispatch ( {
310
+ action : Action . ViewRoom ,
311
+ event_id,
312
+ highlighted : true ,
313
+ room_id : roomId ,
314
+ } ) ;
315
+ } ) ( ) ) ;
316
+ }
317
+
318
+ return reject ( this . getUsage ( ) ) ;
319
+ } ,
320
+ category : CommandCategories . actions ,
321
+ } ) ,
289
322
new Command ( {
290
323
command : 'nick' ,
291
324
args : '<display_name>' ,
0 commit comments