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

Ability to join an arbitrary room and use it as a target for higlights #11 #28

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

Stvad
Copy link
Contributor

@Stvad Stvad commented Jan 3, 2023

There are two TODO sections in the code that need additional discussion.
I'm also not entirely sure I handled the UI/state transitions as intended and would appreciate double-checking on that!

  • upgrade matrix client minor version
  • Add "watch" script for faster iteration
  • Add webextension plugin to enable auto-reload in Chrome to improve iteration speed.
  • Readme dev instructions update
  • Fix chrome build issue (non-ascii symbols in minified version)
  • Join and configure arbitrary room. Iteration 1 (works but has issues) Allow storing highlights on arbitrary rooms #11

@Stvad
Copy link
Contributor Author

Stvad commented Jan 3, 2023

"fixes" #27 too

@DanilaFe
Copy link
Owner

DanilaFe commented Jan 4, 2023

Thanks for your work!

I don't have time to review the whole thing today, but I am somewhat concerned about the added uses of !. Ideally, we wouldn't be using escape hatches for the type system. If this is due to an SDK upgrade (I don't see anh other causes at first glance) I'll need to think about this some more.

Otherwise, about the WebExtension plugin: we're still at manifest V2 with this change, and thus barred from the chrome web store?

@Stvad
Copy link
Contributor Author

Stvad commented Jan 4, 2023

the non-null assertions are indeed because of the SDK upgrade and presumably them improving their types. I agree that ideally we should properly deal with that, but the current change doesn't change things functionally - just highlights that there is a problem we need to deal with 🤷‍♂️

Also, it'd be great to update to the latest major sdk version at some point!

WebExtension plugin: we're still at manifest V2 with this change, and thus barred from the chrome web store?

Yes, though it should make it easier to write a manifest that would be cross-compatible between v2 and v3 (it allows specifying browser-specific fields)

@Stvad Stvad force-pushed the join-arbitrary-rooms branch from 7ef4b86 to 05bb8de Compare January 9, 2023 00:06
@Stvad Stvad force-pushed the join-arbitrary-rooms branch from 05bb8de to cbec6be Compare January 9, 2023 00:12
@Stvad
Copy link
Contributor Author

Stvad commented Jan 17, 2023

Hi, checking in on this! :)

@DanilaFe
Copy link
Owner

Hey @Stvad, sorry about the delay. I really appreciate the work you're putting in. I work a full-time software job nowadays, and in all honesty I'm a little too tired most of the time to do much else software related.

Now, my thinking re: the ! and Room? is that I knew what I was doing when I didn't check for null - I realized that the types were improperly assigned, but I was lazy and didn't bother writing the checks. Now that the checks are finally required, that little laziness debt is to be repayed. However, since you didn't introduce the possible null bugs (I did 😄 ), I think it's fine to merge the ! versions. I'll give the code another read-through now, and maybe merge if everything else looks good!

Thanks again for your help.

Copy link
Owner

@DanilaFe DanilaFe left a comment

Choose a reason for hiding this comment

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

Thank you! I do have a few suggestions / design questions.

src/background/client.ts Outdated Show resolved Hide resolved
Comment on lines +61 to +64
const createEvent = state.getStateEvents("m.room.create", "");
const configEvent = state.getStateEvents(HIGHLIGHT_STATE_EVENT_TYPE, "")

return configEvent?.getContent()?.url || createEvent.getContent()[HIGHLIGHT_PAGE_KEY];
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
const createEvent = state.getStateEvents("m.room.create", "");
const configEvent = state.getStateEvents(HIGHLIGHT_STATE_EVENT_TYPE, "")
return configEvent?.getContent()?.url || createEvent.getContent()[HIGHLIGHT_PAGE_KEY];
const createEvent = state.getStateEvents("m.room.create", "");
const createData = createEvent.getContent()[HIGHLIGHT_PAGE_KEY];
const configEvent = state.getStateEvents(HIGHLIGHT_STATE_EVENT_TYPE, "")
return configEvent?.getContent()?.url || createData;

Though this makes me wonder: we get url out of the config event, but just return the createData from the creation event's content. Is the latter a string? Can the former be made a string (rather than an object?) too?

Reading the JS SDK, looks like an object is required. Oh well!

src/content/App.tsx Show resolved Hide resolved
(event.type === 'room-configured' ||
(event.type === 'room-membership' && event.membership === 'join'))
&& state.tab === 'join') {
newState.tab = null
Copy link
Owner

Choose a reason for hiding this comment

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

Joining a room from other tabs would close the join menu in this tab?

@@ -181,10 +196,17 @@ export class Client {
this._emitEvent(event, false);
});
this._sdkClient.on("Room.timeline", (event: sdk.MatrixEvent, room: sdk.Room, toStartOfTimeline: boolean, removed: boolean, data: {liveEvent: boolean}) => {
if (event.getType() === HIGHLIGHT_STATE_EVENT_TYPE) {
this._emitRoom(room);
Copy link
Owner

Choose a reason for hiding this comment

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

What if we're already in a room (we joined it) and someone else joins and tries to set the state event? Won't this double-count the events then?

@@ -265,4 +289,14 @@ export class Client {
this._loadRoom(message.roomId);
}
}
private async joinAndConfigureRoom(roomId: string, url: string) {
Copy link
Owner

Choose a reason for hiding this comment

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

I'm not sure I like this approach (sorry 😞 ). Barging into a room and trying to set state events just seems... impolite? The use case for explicitly joining a room (rather than being invited, which is a case already handled, I hope) is some sort of public room that stores highlights. But that room would already be configured, then.

I suggest we split the two actions somehow:

  1. Joining a room (this) -- you join an existing room and just assume it has a state event already set (or a create event). Then, the existing Room handler of the matrix client should take care of emitting the room, and all is well.
  2. "Promoting" a room (new) -- take an existing room, that you're in and have permission to modify via state events -- and send the new state event to it, making it a room for your current URL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants