Add `Copy permalink` option to messages (`matrix.to`) (#136)

This might be a little ambiguous since we'll have permalinks within the Matrix Public Archive with `?at=$xxx` (related https://github.com/matrix-org/matrix-public-archive/issues/137) which is different from `matrix.to` permalinks 🤔

But will just go with it for now 
This commit is contained in:
Eric Eastwood 2022-11-14 17:55:00 -06:00 committed by GitHub
parent 11cbf39460
commit b41d15a92c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 30 additions and 30 deletions

14
package-lock.json generated
View File

@ -21,7 +21,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/",
@ -3640,9 +3640,9 @@
},
"node_modules/hydrogen-view-sdk": {
"name": "@mlm/hydrogen-view-sdk",
"version": "0.24.0-scratch",
"resolved": "https://registry.npmjs.org/@mlm/hydrogen-view-sdk/-/hydrogen-view-sdk-0.24.0-scratch.tgz",
"integrity": "sha512-NRH2TTjAaV+8siT6R4vAGJ55fSXT/7w5AdTe+mA6fyyTRKX2esWYFO+TtDSABm4TJmySqUxlUP/Yj+h1kuZ46w==",
"version": "0.25.0-scratch",
"resolved": "https://registry.npmjs.org/@mlm/hydrogen-view-sdk/-/hydrogen-view-sdk-0.25.0-scratch.tgz",
"integrity": "sha512-FgSBCgNbVe/jiy6khdY8ZtbcZ/CRPc1cDPNZM0skUWTnuXzDtzPUQ2dW45yOO951gd+GS01TPhpibjowEOWrow==",
"dependencies": {
"@matrix-org/olm": "https://gitlab.matrix.org/api/v4/projects/27/packages/npm/@matrix-org/olm/-/@matrix-org/olm-3.2.8.tgz",
"another-json": "^0.2.0",
@ -8091,9 +8091,9 @@
}
},
"hydrogen-view-sdk": {
"version": "npm:@mlm/hydrogen-view-sdk@0.24.0-scratch",
"resolved": "https://registry.npmjs.org/@mlm/hydrogen-view-sdk/-/hydrogen-view-sdk-0.24.0-scratch.tgz",
"integrity": "sha512-NRH2TTjAaV+8siT6R4vAGJ55fSXT/7w5AdTe+mA6fyyTRKX2esWYFO+TtDSABm4TJmySqUxlUP/Yj+h1kuZ46w==",
"version": "npm:@mlm/hydrogen-view-sdk@0.25.0-scratch",
"resolved": "https://registry.npmjs.org/@mlm/hydrogen-view-sdk/-/hydrogen-view-sdk-0.25.0-scratch.tgz",
"integrity": "sha512-FgSBCgNbVe/jiy6khdY8ZtbcZ/CRPc1cDPNZM0skUWTnuXzDtzPUQ2dW45yOO951gd+GS01TPhpibjowEOWrow==",
"requires": {
"@matrix-org/olm": "https://gitlab.matrix.org/api/v4/projects/27/packages/npm/@matrix-org/olm/-/@matrix-org/olm-3.2.8.tgz",
"another-json": "^0.2.0",

View File

@ -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/",

View File

@ -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);
@ -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;
},
};

View File

@ -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;

View File

@ -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() {
@ -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