2022-09-20 15:02:09 -06:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const { SimpleTile } = require('hydrogen-view-sdk');
|
|
|
|
|
2023-04-05 03:25:31 -06:00
|
|
|
const { DIRECTION } = require('matrix-public-archive-shared/lib/reference-values');
|
2022-09-20 15:02:09 -06:00
|
|
|
const MatrixPublicArchiveURLCreator = require('matrix-public-archive-shared/lib/url-creator');
|
|
|
|
const assert = require('../lib/assert');
|
|
|
|
|
2022-11-02 03:27:30 -06:00
|
|
|
class JumpToNextActivitySummaryTileViewModel 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);
|
|
|
|
this._matrixPublicArchiveURLCreator = new MatrixPublicArchiveURLCreator(basePath);
|
|
|
|
}
|
|
|
|
|
|
|
|
get shape() {
|
2022-11-02 03:27:30 -06:00
|
|
|
return 'org.matrix.archive.jump_to_next_activity_summary:shape';
|
2022-09-20 15:02:09 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
get daySummaryKind() {
|
|
|
|
return this._entry?.content?.['daySummaryKind'];
|
|
|
|
}
|
|
|
|
|
|
|
|
get dayTimestamp() {
|
|
|
|
return this._entry?.content?.['dayTimestamp'];
|
|
|
|
}
|
|
|
|
|
2023-04-05 03:25:31 -06:00
|
|
|
// The start of the range to use as a jumping off point to the previous activity
|
|
|
|
get jumpRangeStartTimestamp() {
|
|
|
|
return this._entry?.content?.['jumpRangeStartTimestamp'];
|
|
|
|
}
|
|
|
|
|
2022-09-20 15:02:09 -06:00
|
|
|
// The end of the range to use as a jumping off point to the next activity
|
2023-04-05 03:25:31 -06:00
|
|
|
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-09-20 15:02:09 -06:00
|
|
|
get jumpToNextActivityUrl() {
|
2022-10-27 00:09:13 -06:00
|
|
|
return this._matrixPublicArchiveURLCreator.archiveJumpUrlForRoom(
|
|
|
|
this._entry?.content?.['canonicalAlias'] || this._entry.roomId,
|
|
|
|
{
|
2023-04-05 03:25:31 -06:00
|
|
|
dir: DIRECTION.forward,
|
|
|
|
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 = JumpToNextActivitySummaryTileViewModel;
|