Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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