Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Implement TextualEvent tiles for im.vector.modular.widgets #1312

Merged
merged 7 commits into from
Aug 18, 2017

Conversation

lukebarnard1
Copy link
Contributor

E.g. "Bob added a Acme widget", "Susan removed a Giraffe widget" The name is calculated by taking the name in the event content, falling back on the type, falling back on the previous content type. This is then capitalised.

Should be squash merged.

Luke Barnard added 4 commits August 16, 2017 17:46
E.g. "Bob added a Acme widget", "Susan removed a Giraffe widget"
E.g. "Bob added a Acme widget", "Susan removed a Giraffe widget"

The name is calculated by taking the `name` in the event content, falling back on the `type`, falling back on the previous content `type`. This is then capitalised.
…ix-org/matrix-react-sdk into luke/feature-widget-timeline-events
Copy link
Contributor

@superdump superdump left a comment

Choose a reason for hiding this comment

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

A couple of probably minor comments to address but LGTM after that.

@@ -248,6 +248,26 @@ function textForPowerEvent(event) {
});
}

function textForWidgetEvent(event) {
const senderName = event.sender ? event.sender.name : event.getSender();
const previousContent = event.getPrevContent() ? event.getPrevContent() : {};
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know how costly a called to getPrevContent() is, but in JavaScript I think the idiom is:

const previousContent = event.getPrevContent() || {};

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh. absolutely

function textForWidgetEvent(event) {
const senderName = event.sender ? event.sender.name : event.getSender();
const previousContent = event.getPrevContent() ? event.getPrevContent() : {};
const {name, type, url} = event.getContent() ? event.getContent() : {};
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here: const {name, type, url} = event.getContent() || {};

let widgetName = widgetName || name || type || previousContent.type || '';

// Apply sentence case
widgetName = widgetName ? widgetName[0].toUpperCase() + widgetName.slice(1).toLowerCase() + ' ' : '';
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any good reason to lower-case the rest of the string? I think maybe preserving the case of the rest of the string is better. That is, just upper-case the first character and leave the rest as it is.

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 is the same logic applied to the app tile header, I was going for consistency. Ideally the name would be formatted as intended for human reading by Scalar itself.

Copy link
Contributor

Choose a reason for hiding this comment

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

OK. Fine by me.

// Apply sentence case
widgetName = widgetName ? widgetName[0].toUpperCase() + widgetName.slice(1).toLowerCase() + ' ' : '';

if (url) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Technically if the widget state event has no content, then it has been removed, but I think this is sufficiently equivalent as having a url is required.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I shall comment this, thanks

@lukebarnard1 lukebarnard1 assigned superdump and unassigned rxl881 Aug 18, 2017
@superdump
Copy link
Contributor

LGTM.

@lukebarnard1 lukebarnard1 merged commit cab3123 into develop Aug 18, 2017
lukebarnard1 pushed a commit that referenced this pull request Aug 18, 2017
This was caused by a broken assumption which was AppsDrawer component mounting === clicking on apps draw toggle.

This was introduced in #1312.

Known issue with this fix: deleting the last app doesn't hide the app drawer.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants