2022-09-20 15:02:09 -06:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const { SimpleTile } = require('hydrogen-view-sdk');
|
|
|
|
|
2023-07-14 14:52:35 -06:00
|
|
|
const { DIRECTION } = require('matrix-viewer-shared/lib/reference-values');
|
|
|
|
const MatrixViewerURLCreator = require('matrix-viewer-shared/lib/url-creator');
|
2022-09-20 15:02:09 -06:00
|
|
|
const assert = require('../lib/assert');
|
|
|
|
|
2022-11-02 03:27:30 -06:00
|
|
|
class JumpToPreviousActivitySummaryTileViewModel extends SimpleTile {
|
2022-09-20 15:02:09 -06:00
|
|
|
constructor(entry, options) {
|
|
|
|
super(entry, options);
|
|
|
|
this._entry = entry;
|
|
|
|
|
|
|
|
const basePath = this._entry?.content?.['basePath'];
|
|
|
|
assert(basePath);
|
2023-07-14 14:52:35 -06:00
|
|
|
this._matrixViewerURLCreator = new MatrixViewerURLCreator(basePath);
|
2022-09-20 15:02:09 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
get shape() {
|
2023-07-14 14:52:35 -06:00
|
|
|
return 'org.matrix.viewer.jump_to_previous_activity_summary:shape';
|
2022-09-20 15:02:09 -06:00
|
|
|
}
|
|
|
|
|
2022-11-02 03:27:30 -06:00
|
|
|
// The start of the range to use as a jumping off point to the previous activity
|
2023-04-05 03:25:31 -06:00
|
|
|
get jumpRangeStartTimestamp() {
|
|
|
|
return this._entry?.content?.['jumpRangeStartTimestamp'];
|
|
|
|
}
|
|
|
|
|
|
|
|
// The end of the range to use as a jumping off point to the next activity
|
|
|
|
get jumpRangeEndTimestamp() {
|
|
|
|
return this._entry?.content?.['jumpRangeEndTimestamp'];
|
2022-09-20 15:02:09 -06:00
|
|
|
}
|
|
|
|
|
2023-04-19 00:26:15 -06:00
|
|
|
// The first event shown in the timeline.
|
|
|
|
get timelineStartEventId() {
|
|
|
|
return this._entry?.content?.['timelineStartEventId'];
|
|
|
|
}
|
|
|
|
|
|
|
|
// The last event shown in the timeline.
|
|
|
|
get timelineEndEventId() {
|
|
|
|
return this._entry?.content?.['timelineEndEventId'];
|
|
|
|
}
|
|
|
|
|
2022-11-02 03:27:30 -06:00
|
|
|
get jumpToPreviousActivityUrl() {
|
2023-07-14 14:52:35 -06:00
|
|
|
return this._matrixViewerURLCreator.jumpUrlForRoom(
|
2022-10-27 00:09:13 -06:00
|
|
|
this._entry?.content?.['canonicalAlias'] || this._entry.roomId,
|
|
|
|
{
|
2023-04-05 03:25:31 -06:00
|
|
|
dir: DIRECTION.backward,
|
|
|
|
currentRangeStartTs: this.jumpRangeStartTimestamp,
|
|
|
|
currentRangeEndTs: this.jumpRangeEndTimestamp,
|
2023-04-19 00:26:15 -06:00
|
|
|
timelineStartEventId: this.timelineStartEventId,
|
|
|
|
timelineEndEventId: this.timelineEndEventId,
|
2022-10-27 00:09:13 -06:00
|
|
|
}
|
|
|
|
);
|
2022-09-20 15:02:09 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-02 03:27:30 -06:00
|
|
|
module.exports = JumpToPreviousActivitySummaryTileViewModel;
|