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 1 commit
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/sdk/base-manifest.json
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
3 changes: 2 additions & 1 deletion src/domain/session/room/timeline/tiles/BaseMessageTile.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export class BaseMessageTile extends SimpleTile {
}

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

get isContinuation() {
Expand Down Expand Up @@ -124,6 +124,7 @@ export class BaseMessageTile extends SimpleTile {

updateEntry(entry, param, tilesCreator) {
const action = super.updateEntry(entry, param, tilesCreator);
console.log('updateEntry', entry);
if (action.shouldUpdate) {
this._updateReactions();
}
Expand Down
7 changes: 7 additions & 0 deletions src/lib.ts
Original file line number Diff line number Diff line change
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";
10 changes: 8 additions & 2 deletions src/matrix/room/timeline/Timeline.js
Original file line number Diff line number Diff line change
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 @@ -186,6 +187,8 @@ export class Timeline {
}

_addLocalRelationsToNewRemoteEntries(entries) {
console.log('_addLocalRelationsToNewRemoteEntries entries', entries)
console.log('this._localEntries?.hasSubscriptions entries', this._localEntries?.hasSubscriptions)
// because it is not safe to iterate a derived observable collection
// before it has any subscriptions, we bail out if this isn't
// the case yet. This can happen when sync adds or replaces entries
Expand All @@ -199,8 +202,11 @@ export class Timeline {
if (!this._localEntries?.hasSubscriptions) {
return;
}
// find any local relations to this new remote event
for (const pee of this._localEntries) {
console.log('after')
// 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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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