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

Draft: Scratch changes for matrix-public-archive #653

Draft
wants to merge 71 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
dcc508c
Changes added to work on the Matrix public archive
MadLittleMods Feb 2, 2022
5805ce0
Remove some scratch changes
MadLittleMods Feb 2, 2022
eda179a
Remove dom side-effect from rendering
MadLittleMods Feb 4, 2022
4eb24db
Fix reply tiles not showing the new message
MadLittleMods Feb 9, 2022
8d0c4e6
Some changes to support RoomView with no composer
MadLittleMods Feb 10, 2022
e75f18c
Support custom RightPanel content
MadLittleMods Feb 10, 2022
48825ea
Use explicit HTML document boilerplate to get consistent results in b…
MadLittleMods Feb 12, 2022
1032f4d
Merge branch 'master' into madlittlemods/matrix-public-archive-scratc…
MadLittleMods Feb 14, 2022
6005fcf
Add permalink to timestamp
MadLittleMods Feb 24, 2022
a4cdde6
Use UTC timestamps and add data attribute for easy targeting in tests
MadLittleMods Feb 24, 2022
3e58619
Add more SVG elements
MadLittleMods Feb 24, 2022
fc89bfd
Get rid of duplicate export
MadLittleMods Feb 24, 2022
082d997
Only try to use window.crypto.subtle in secure contexts to avoid it t…
MadLittleMods Feb 24, 2022
ea2d45c
No need to comment this out since linkedom supports it now
MadLittleMods Feb 25, 2022
c24ac43
Merge branch 'master' into madlittlemods/matrix-public-archive-scratc…
MadLittleMods Jun 6, 2022
ae67386
Use correct variable in comment
MadLittleMods Jun 6, 2022
2d3b78b
WIP: Make the lightbox open, not working yet
MadLittleMods Jun 7, 2022
1a0b140
Working lightbox pops up and closes
MadLittleMods Jun 7, 2022
5d9dc63
URL hashes relative to the room of the archive
MadLittleMods Jun 8, 2022
72300d1
Lightbox escape keyboard shortcut also works
MadLittleMods Jun 8, 2022
6a6f220
Merge branch 'master' into madlittlemods/matrix-public-archive-scratc…
MadLittleMods Jul 5, 2022
8dc3c13
Ignore missing events
MadLittleMods Jul 20, 2022
871cf1a
Revert "Ignore missing events"
MadLittleMods Jul 20, 2022
c824012
`this` doesn't work in strict mode which the SDK is exported as
MadLittleMods Jul 21, 2022
b54e884
Expose error when we fail to createObjectStore
MadLittleMods Jul 21, 2022
88e2470
Scope log
MadLittleMods Jul 22, 2022
acaf53d
More exports
MadLittleMods Jul 22, 2022
7c87e06
WIP: Custom room header
MadLittleMods Aug 30, 2022
c62c047
Merge branch 'master' into madlittlemods/matrix-public-archive-scratc…
MadLittleMods Aug 30, 2022
36f26a0
Try fix no composer
MadLittleMods Aug 30, 2022
bdf820a
Include SDK asset build fix from https://github.com/vector-im/hydroge…
MadLittleMods Aug 30, 2022
eb470fa
Scratch changes for responsive and toggling right-panel via room header
MadLittleMods Aug 30, 2022
f2baf3d
Seems like an unused style that collides with styles in the archive t…
MadLittleMods Aug 30, 2022
fa0e487
Remove custom `none` composer in favor of useful HTML message in the …
MadLittleMods Aug 30, 2022
98e0dd9
Make changes for stubbed PowerLevels
MadLittleMods Aug 31, 2022
921544a
Add header/footer
MadLittleMods Sep 3, 2022
d5ba256
More necessary exports
MadLittleMods Sep 8, 2022
7710580
Add style tag for adding dynamic debugging styles
MadLittleMods Sep 15, 2022
89d044c
Add data-event-id to the AnnouncementView
MadLittleMods Sep 16, 2022
127f39a
Log error caught in boundary to the console
MadLittleMods Sep 16, 2022
fa524d9
Add support for developer-options navigation
MadLittleMods Sep 17, 2022
5ab01b6
Extra style for reference by children
MadLittleMods Sep 20, 2022
de261aa
Be able to access the event room_id
MadLittleMods Sep 20, 2022
e0e4868
Make the summary stick to the bottom
MadLittleMods Sep 20, 2022
4d789bd
Merge branch 'master' into madlittlemods/matrix-public-archive-scratc…
MadLittleMods Oct 14, 2022
c94765e
Add new elements
MadLittleMods Oct 19, 2022
7d4f2b3
Merge branch 'madlittlemods/matrix-public-archive-scratch-changes' of…
MadLittleMods Oct 19, 2022
26cb86e
Add export
MadLittleMods Oct 20, 2022
8911be8
Merge branch 'master' into madlittlemods/matrix-public-archive-scratc…
MadLittleMods Oct 20, 2022
9f5e66e
Add details element
MadLittleMods Oct 21, 2022
1d9c1bf
Add a way to change the anchor position to the top of a node
MadLittleMods Nov 1, 2022
4e3f397
Revert "Add a way to change the anchor position to the top of a node"
MadLittleMods Nov 1, 2022
5fdbe61
Add a way to toggle scrollToBottom so you can start scroll from the t…
MadLittleMods Nov 2, 2022
c9859ff
Add a way to change the anchor position to the top of a node
MadLittleMods Nov 1, 2022
7602825
Re-add way to align scroll top to event
MadLittleMods Nov 3, 2022
dc6ab45
Add a way to highlight tiles
MadLittleMods Nov 3, 2022
ceca3d1
Add a way to scroll to the given highlighted event
MadLittleMods Nov 3, 2022
b84dd3b
Fix tsc error
MadLittleMods Nov 3, 2022
65ec71b
Prevent messages nested in a reply from being highlighted
MadLittleMods Nov 3, 2022
168788d
Add MXID as title tooltip
MadLittleMods Nov 9, 2022
847482f
Add full MXID to message avatar/sender
MadLittleMods Nov 9, 2022
bb51174
Fix AnnouncementView member events not highlighting
MadLittleMods Nov 9, 2022
07cc95c
Add different hover styles so it's more obvious if you page-load with…
MadLittleMods Nov 9, 2022
7c52de3
Merge branch 'master' into madlittlemods/matrix-public-archive-scratc…
MadLittleMods Nov 10, 2022
64b6ba1
Add copy permalink action
MadLittleMods Nov 11, 2022
72837d8
Remove matrix.to link from message timestamp since we have an context…
MadLittleMods Nov 12, 2022
84029d5
Merge branch 'master' into madlittlemods/matrix-public-archive-scratc…
MadLittleMods Apr 26, 2023
987d27a
Increase width to accomodate long dates with year like 'Wednesday, No…
MadLittleMods Apr 26, 2023
ba0eb55
Add ApplyMap to exports
MadLittleMods May 3, 2023
f1ec4d4
Add MXC URL's as data-attribute for easy reference
MadLittleMods May 11, 2023
8034c53
Backport fix to make SDK depedencies available when npm linking
MadLittleMods May 26, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/sdk/base-manifest.json
Expand Up @@ -2,6 +2,6 @@
"name": "hydrogen-view-sdk",
"description": "Embeddable matrix client library, including view components",
"version": "0.0.4",
"main": "./hydrogen.es.js",
"main": "./lib-build/hydrogen.es.js",
MadLittleMods marked this conversation as resolved.
Show resolved Hide resolved
"type": "module"
}
2 changes: 1 addition & 1 deletion scripts/sdk/build.sh
@@ -1,5 +1,5 @@
#!/bin/bash
rm -rf target
rm -rf target/*
yarn run vite build -c vite.sdk-assets-config.js
yarn run vite build -c vite.sdk-lib-config.js
yarn tsc -p tsconfig-declaration.json
Expand Down
2 changes: 2 additions & 0 deletions src/domain/session/room/RoomViewModel.js
Expand Up @@ -21,6 +21,7 @@ import {avatarInitials, getIdentifierColorNumber, getAvatarHttpUrl} from "../../
import {tilesCreator} from "./timeline/tilesCreator.js";
import {ViewModel} from "../../ViewModel.js";

console.log('RoomViewModel asdfwafeawfefewfewaeafwafewefw');
export class RoomViewModel extends ViewModel {
constructor(options) {
super(options);
Expand All @@ -45,6 +46,7 @@ export class RoomViewModel extends ViewModel {
this._room.on("change", this._onRoomChange);
try {
const timeline = await this._room.openTimeline();
console.log('timeline', timeline.entries);
this._tilesCreator = tilesCreator(this.childOptions({
roomVM: this,
timeline,
Expand Down
1 change: 1 addition & 0 deletions src/domain/session/room/timeline/TimelineViewModel.js
Expand Up @@ -36,6 +36,7 @@ import {ViewModel} from "../../../ViewModel.js";

export class TimelineViewModel extends ViewModel {
constructor(options) {
console.log('TimelineViewModel asdf', options)
super(options);
const {timeline, tilesCreator} = options;
this._timeline = this.track(timeline);
Expand Down
2 changes: 1 addition & 1 deletion src/domain/session/room/timeline/tiles/BaseMessageTile.js
Expand Up @@ -87,7 +87,7 @@ export class BaseMessageTile extends SimpleTile {
}

get isOwn() {
return this._entry.sender === this._ownMember.userId;
return this._entry.sender === this._ownMember?.userId;
}

get isContinuation() {
Expand Down
7 changes: 7 additions & 0 deletions src/lib.ts
Expand Up @@ -24,5 +24,12 @@ export {SessionViewModel} from "./domain/session/SessionViewModel.js";
export {SessionView} from "./platform/web/ui/session/SessionView.js";
export {RoomViewModel} from "./domain/session/room/RoomViewModel.js";
export {RoomView} from "./platform/web/ui/session/room/RoomView.js";
export {MediaRepository} from "./matrix/net/MediaRepository";
export {TilesCollection} from "./domain/session/room/timeline/TilesCollection.js";
export {tilesCreator} from "./domain/session/room/timeline/tilesCreator.js";
export {FragmentIdComparer} from "./matrix/room/timeline/FragmentIdComparer.js";
export {EventEntry} from "./matrix/room/timeline/entries/EventEntry.js";
export {encodeKey, decodeKey, encodeEventIdKey, decodeEventIdKey} from "./matrix/storage/idb/stores/TimelineEventStore";
export {Timeline} from "./matrix/room/timeline/Timeline.js";
export {TimelineViewModel} from "./domain/session/room/timeline/TimelineViewModel.js";
export {TimelineView} from "./platform/web/ui/session/room/TimelineView";
7 changes: 5 additions & 2 deletions src/matrix/room/timeline/Timeline.js
Expand Up @@ -86,6 +86,7 @@ export class Timeline {
const readerRequest = this._disposables.track(this._timelineReader.readFromEnd(20, txn, log));
try {
const entries = await readerRequest.complete();
console.log('entries', entries)
this._loadContextEntriesWhereNeeded(entries);
this._setupEntries(entries);
} finally {
Expand Down Expand Up @@ -199,8 +200,10 @@ export class Timeline {
if (!this._localEntries?.hasSubscriptions) {
return;
}
// find any local relations to this new remote event
for (const pee of this._localEntries) {
// find any local relations to these new remote events or maybe these
// new remote events reference one of the other new remote events we have.
const entryList = new ConcatList(entries, this._localEntries);
for (const pee of entryList) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes emoji reactions show up on messages.

(the m.reaction events are in the list of events we're rendering)

Comment on lines +202 to +205
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Split off to #860

// this will work because we set relatedEventId when removing remote echos
if (pee.relatedEventId) {
const relationTarget = entries.find(e => e.id === pee.relatedEventId);
Expand Down
1 change: 1 addition & 0 deletions src/matrix/room/timeline/persistence/TimelineReader.js
Expand Up @@ -54,6 +54,7 @@ async function readRawTimelineEntriesWithTxn(roomId, eventKey, direction, amount
} else {
eventsWithinFragment = await timelineStore.eventsBefore(roomId, eventKey, amount);
}
console.log('readRawTimelineEntriesWithTxn eventsWithinFragment', eventsWithinFragment)
let eventEntries = eventsWithinFragment.map(e => new EventEntry(e, fragmentIdComparer));
entries = directionalConcat(entries, eventEntries, direction);
// prepend or append eventsWithinFragment to entries, and wrap them in EventEntry
Expand Down
8 changes: 4 additions & 4 deletions src/matrix/storage/idb/stores/TimelineEventStore.ts
Expand Up @@ -40,20 +40,20 @@ interface TimelineEventEntry {

type TimelineEventStorageEntry = TimelineEventEntry & { key: string, eventIdKey: string };

function encodeKey(roomId: string, fragmentId: number, eventIndex: number): string {
export function encodeKey(roomId: string, fragmentId: number, eventIndex: number): string {
return `${roomId}|${encodeUint32(fragmentId)}|${encodeUint32(eventIndex)}`;
}

function decodeKey(key: string): { roomId: string, eventKey: EventKey } {
export function decodeKey(key: string): { roomId: string, eventKey: EventKey } {
const [roomId, fragmentId, eventIndex] = key.split("|");
return {roomId, eventKey: new EventKey(decodeUint32(fragmentId), decodeUint32(eventIndex))};
}

function encodeEventIdKey(roomId: string, eventId: string): string {
export function encodeEventIdKey(roomId: string, eventId: string): string {
return `${roomId}|${eventId}`;
}

function decodeEventIdKey(eventIdKey: string): { roomId: string, eventId: string } {
export function decodeEventIdKey(eventIdKey: string): { roomId: string, eventId: string } {
const [roomId, eventId] = eventIdKey.split("|");
return {roomId, eventId};
}
Expand Down
5 changes: 4 additions & 1 deletion src/platform/web/parsehtml.js
Expand Up @@ -64,6 +64,9 @@ export function parseHTML(html) {
// If DOMPurify uses DOMParser, can't we just get the built tree from it
// instead of re-parsing?
const sanitized = DOMPurify.sanitize(html, sanitizeConfig);
const bodyNode = new DOMParser().parseFromString(sanitized, "text/html").body;
// FIXME: DOMParser from linkedom does not behave the same as the browser,
// see https://github.com/WebReflection/linkedom/issues/106
const bodyNode = new DOMParser().parseFromString(`<body>${sanitized}</body>`, "text/html").documentElement;
MadLittleMods marked this conversation as resolved.
Show resolved Hide resolved

return new HTMLParseResult(bodyNode);
}
2 changes: 1 addition & 1 deletion src/platform/web/ui/session/room/TimelineView.ts
Expand Up @@ -59,7 +59,7 @@ export class TimelineView extends TemplateView<TimelineViewModel> {
// assume this view will be mounted in the parent DOM straight away
requestAnimationFrame(() => {
// do initial scroll positioning
this.restoreScrollPosition();
//this.restoreScrollPosition();
MadLittleMods marked this conversation as resolved.
Show resolved Hide resolved
});
this.tilesView = new TilesListView(vm.tiles, () => this.restoreScrollPosition());
const root = t.div({className: "Timeline"}, [
Expand Down