Skip to content

Commit

Permalink
Add Copy permalink option to messages (matrix.to) (#136)
Browse files Browse the repository at this point in the history
This might be a little ambiguous since we'll have permalinks within the Matrix Public Archive with `?at=$xxx` (related #137) which is different from `matrix.to` permalinks 🤔

But will just go with it for now ⏩
  • Loading branch information
MadLittleMods authored Nov 14, 2022
1 parent 11cbf39 commit b41d15a
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 30 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"@opentelemetry/semantic-conventions": "^1.3.1",
"dompurify": "^2.3.9",
"express": "^4.17.2",
"hydrogen-view-sdk": "npm:@mlm/hydrogen-view-sdk@^0.24.0-scratch",
"hydrogen-view-sdk": "npm:@mlm/hydrogen-view-sdk@^0.25.0-scratch",
"json5": "^2.2.1",
"linkedom": "^0.14.17",
"matrix-public-archive-shared": "file:./shared/",
Expand Down
25 changes: 3 additions & 22 deletions shared/hydrogen-vm-render-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,13 @@
// Data is passed in via `window.matrixPublicArchiveContext`

const assert = require('matrix-public-archive-shared/lib/assert');
const {
Platform,
MediaRepository,
createNavigation,
createRouter,

RetainedObservableValue,
PowerLevels,
} = require('hydrogen-view-sdk');
const { Platform, MediaRepository, createNavigation, createRouter } = require('hydrogen-view-sdk');

const ArchiveRoomView = require('matrix-public-archive-shared/views/ArchiveRoomView');
const ArchiveHistory = require('matrix-public-archive-shared/lib/archive-history');
const supressBlankAnchorsReloadingThePage = require('matrix-public-archive-shared/lib/supress-blank-anchors-reloading-the-page');
const ArchiveRoomViewModel = require('matrix-public-archive-shared/viewmodels/ArchiveRoomViewModel');
const stubPowerLevelsObservable = require('matrix-public-archive-shared/lib/stub-powerlevels-observable');

const fromTimestamp = window.matrixPublicArchiveContext.fromTimestamp;
assert(fromTimestamp);
Expand Down Expand Up @@ -98,19 +91,7 @@ async function mountHydrogen() {
mediaRepository: mediaRepository,
// Based on https://github.com/vector-im/hydrogen-web/blob/5f9cfffa3b547991b665f57a8bf715270a1b2ef1/src/matrix/room/BaseRoom.js#L480
observePowerLevels: async function () {
let powerLevelsObservable = this._powerLevelsObservable;
if (!powerLevelsObservable) {
const powerLevels = new PowerLevels({
powerLevelEvent: {},
ownUserId: 'xxx-ownUserId',
membership: null,
});
powerLevelsObservable = new RetainedObservableValue(powerLevels, () => {
this._powerLevels = null;
});
this._powerLevelsObservable = powerLevelsObservable;
}
return powerLevelsObservable;
return stubPowerLevelsObservable;
},
};

Expand Down
17 changes: 17 additions & 0 deletions shared/lib/stub-powerlevels-observable.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
'use strict';

const { RetainedObservableValue, PowerLevels } = require('hydrogen-view-sdk');

// Fake power levels for viewing the room anonymously
const stubPowerLevels = new PowerLevels({
powerLevelEvent: {},
ownUserId: 'xxx-ownUserId',
membership: null,
});
const stubPowerLevelsObservable = new RetainedObservableValue(stubPowerLevels, () => {
// freeCallback
//
// I don't think we need to do anything here 🤷
});

module.exports = stubPowerLevelsObservable;
2 changes: 2 additions & 0 deletions shared/viewmodels/ArchiveRoomViewModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const AvatarViewModel = require('matrix-public-archive-shared/viewmodels/AvatarV
const {
customTileClassForEntry,
} = require('matrix-public-archive-shared/lib/custom-tile-utilities');
const stubPowerLevelsObservable = require('matrix-public-archive-shared/lib/stub-powerlevels-observable');

let txnCount = 0;
function getFakeEventId() {
Expand Down Expand Up @@ -371,6 +372,7 @@ class ArchiveRoomViewModel extends ViewModel {
fragmentIdComparer: fragmentIdComparer,
clock: this.platform.clock,
logger: this.platform.logger,
powerLevelsObservable: stubPowerLevelsObservable,
});

// Something we can modify with new state updates as we see them
Expand Down

0 comments on commit b41d15a

Please sign in to comment.