-
Notifications
You must be signed in to change notification settings - Fork 27
refactor(list): Detangle canvastable, messagedisplay, virtualtable #1712
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
base: shadowbas/feat-accessible-table
Are you sure you want to change the base?
refactor(list): Detangle canvastable, messagedisplay, virtualtable #1712
Conversation
- Improves on the less accessible canvastable. - Introduces multi select using ctrl and shift. - Reduces memory footprint by a good margin.
…nt virtual scroll table
…Implement virtual scroll table
…list): Implement virtual scroll table
…essage-list): Implement virtual scroll table
… feat(message-list): Implement virtual scroll table
… fixup! feat(message-list): Implement virtual scroll table
|
@castaway , the issue you are experiencing is likely due to the early return. In the virtual table we EDIT: Another possibility is that between the renderRangeChange event and the rowsSubject emit we do not manage the state correctly or stop somewhere in that flow. |
| if (index >= this.rows.length) break | ||
|
|
||
| this.rows[index] = this.canvastable.rows.getRowData(index, this) | ||
| this.rows[index].plaintext = this.searchService.messageText(this.rows[index].id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This returns a promise. This is necessary for the async filter in the template to result in a redraw once the messageText is fetched.
I believe https://github.com/runbox/runbox7/pull/1712/files#diff-884f7f49640e5923f6bcac4c51d90340330a178f662defbe61e5f5aac1c512deR1618 is not a promise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm have run it checking this, and its not returning here (the messagedisplay does exist) .. still baffled how renderedRange(Stream) changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gah i dunno why this comment was here.. I was referring to a different one!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The following callback is used in the template and listens for an event from the virtual scroll table component. That component emits this event.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to be extra clear. Child component state should only be communicated to parent through events (@Output) and not through mutation.
This is a principle common in most frontend frameworks.
Yes one can deviate from this but often that breaks the isolation principle, making a component tangled with state management.
|
|
||
| // local messagelist copy | ||
| // we have a copy in messagelist service, and another in here.. | ||
| this.messagedisplay.enrichRow(messageIdMap.get(msg['mid']), msg.text.text, this); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is bad practice to pass the this of a complete component to some other module.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree! Your code does it a bunch, I have been trying to figure out how not to do it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simplest is to have enrichRow return and then mutate the component state. We we should not have a different module mutate state on the app component.
Another solution is to have the state live in another module/class (isolated) and be able to get a clone or do a prototype inheritance with (Object.create) to prevent mutating the isolated state.
// Encapsulated in the messages module/service
await this.messages.enrichRow(messageIdMap.get(msg['mid']))
this.messages = this.messages.list();
// or have the state in app.
this.messages[index] = await this.messages.enrichedRow(msg)bf4ca21 to
c55e4a9
Compare
dfe1a65 to
db20725
Compare
An initial start on blending the new messagelist via virtual table, into the existing MessageDisplay based "whats displayed" management:
[items]=messagedisplay.displayRowsin the template, however I am not yet understanding the purpose of therowsSubject(another copy?) not thedebouncedRows$which isn't referenced anywhere?Still Todo/Understand:
canvastable.rows.removeMessagescalls tomessagedisplay.removeMessages, but - how to actually update what is displayed in the list?app.rowSelected+ models for message selection/filtering etc should, imo, also live in the MessageDisplay classErrors/Issues: