Skip to content
This repository has been archived by the owner on Mar 12, 2020. It is now read-only.

@sarahscott => [Messaging] WIP on updating messages connection/fragment #630

Merged
merged 13 commits into from
Jun 27, 2017

Conversation

mzikherman
Copy link
Contributor

This uses the updated schema from artsy/metaphysics#680

It doesn't have the real Relay fragment yet...but the existing stuff does work (raw_text instead of snippet), and we now have is_from_user coming back from Metaphysics. I need to go back and do that in a more 'proper' way, but that should be transparent to Emission anyway.

screen shot 2017-06-23 at 4 32 11 pm

package.json Outdated
@@ -29,7 +29,7 @@
"tslint": "tslint",
"sync-colors": "cd externals/elan && git fetch && git checkout origin/master && cp components/lib/variables/colors.json ../../data",
"sync-externals": "npm run-script sync-schema && npm run-script sync-colors",
"sync-schema": "cd externals/metaphysics && git fetch && git checkout origin/master && yarn install && npm run dump-schema -- ../../data && rm -rf node_modules",
"sync-schema": "cd externals/metaphysics && git fetch && git checkout origin/message_details_from_impulse && yarn install && npm run dump-schema -- ../../data && rm -rf node_modules",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will undo once Metaphysics is merged...

Copy link
Contributor

Choose a reason for hiding this comment

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

@mzikherman small tip:

You can run the following command locally to sync the schema of a metaphysics branch you're currently working on

cd <metaphysics_root_dir> && npm run dump-schema -- <path_to_emission_root>/data

@@ -61,14 +61,6 @@ const ComposerContainer = styled.View`
`

export class Conversation extends React.Component<RelayProps, any> {
isFromUser(message) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

👋

Copy link
Contributor

Choose a reason for hiding this comment

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

🙌

@@ -9,6 +9,8 @@ if (Emission && Emission.useStagingEnvironment) {
metaphysicsURL = "https://metaphysics-production.artsy.net"
}

metaphysicsURL = "http://localhost:5001"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Once Metaphysics is merged, will undo.

Copy link
Contributor

Choose a reason for hiding this comment

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

👍 - will need changing

@mzikherman
Copy link
Contributor Author

So, I have this sorta working, w/o Relay fragments :(

screen shot 2017-06-26 at 6 39 55 pm

(image previews, is_from_user, correct timestamps)

Where I'm at is that replacing the explicit queries with Message.getFragment(..) style (and presumably I'll refactor my ImagePreview into some Attachment.getFragment(..) stuff once I add PDFs, basically fails with strange and hard to debug errors.

So, I'm assuming that's a Relay issue, but for the life of me I couldn't figure it out. Some of the commits in artsy/metaphysics#680 were helping, I think (such as implementing the NodeInterface stuff), but still wasn't working.

Either way, let's pair! If I get this in a mergeable state we could even do that, and figuring out the proper fragment thing can be next.

const messageData = conversation.messages.edges.reverse().map(({ node }, index) => {
return {
senderName: this.isFromUser(node) ? conversation.from.name : partnerName,
key: index,
Copy link
Contributor

Choose a reason for hiding this comment

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

In ListViews and FlatLists, every item has to have a unique key. Usually we just use the id or __id of the object; whichever one is numeric.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah got it. That explains those warnings!

}
const messages = this.props.me.conversation.messages.edges.map(({ node }, index) => {
node.first_message = index === 0
node.key = node.id
Copy link
Contributor

Choose a reason for hiding this comment

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

🔑

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🔒

@sarahscott
Copy link
Contributor

So this now runs locally for me, although I haven't tried the ImagePreview fragment yet because I have no messages with attachments right now. @mzikherman does it work for you?

package.json Outdated
@@ -29,7 +29,7 @@
"tslint": "tslint",
"sync-colors": "cd externals/elan && git fetch && git checkout origin/master && cp components/lib/variables/colors.json ../../data",
"sync-externals": "npm run-script sync-schema && npm run-script sync-colors",
"sync-schema": "cd externals/metaphysics && git fetch && git checkout origin/master && yarn install && npm run dump-schema -- ../../data && rm -rf node_modules",
"sync-schema": "cd externals/metaphysics && git fetch && git checkout origin/message_details_from_impulse && yarn install && npm run dump-schema -- ../../data && rm -rf node_modules",
Copy link
Contributor

Choose a reason for hiding this comment

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

@mzikherman small tip:

You can run the following command locally to sync the schema of a metaphysics branch you're currently working on

cd <metaphysics_root_dir> && npm run dump-schema -- <path_to_emission_root>/data

import OpaqueImageView from "../../../OpaqueImageView"

const Container = styled.View`
borderWidth: 1
Copy link
Contributor

Choose a reason for hiding this comment

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

For consistency, use border-width style instead of camel case. Also, add semicolons at the end.

I'll add this package in my next PR to enforce css style
https://github.com/styled-components/stylelint-processor-styled-components

Copy link
Contributor

Choose a reason for hiding this comment

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

Make sure to add stylefmt too so that it's automated: #599

Copy link
Contributor

Choose a reason for hiding this comment

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

kebab-case please @mzikherman

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, don't bother - I will get this right now: https://twitter.com/rauchg/status/879752736467591168

Copy link
Contributor

Choose a reason for hiding this comment

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

in a separate PR

@@ -25,6 +25,8 @@ interface Props {
/** Any additional styling for the imageview */
style?: any

skipGemini?: boolean
Copy link
Contributor

Choose a reason for hiding this comment

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

what does skipGemini mean?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah sorry, didn't know we had a service named gemini 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

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

lol, yea so the OpaqueImageView seems to have an overlay and then a resized on-the-fly image.

However...in testing yesterday it looks like the S3 URL's that are returned by Radiation which links to the attachment, error out when trying to resize with Gemini.

So this means that for now, it just renders the actual attachment (even for the tiny preview).

Later today I'll discuss with @joeyAghion / @ashkan18 the possibility of fixing up how Gemini resizes these (to avoid the error), or (possibly better), pre-render small thumbnails for image attachments. Then we could just serve those directly.

Copy link
Contributor

Choose a reason for hiding this comment

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

Makes sense

@@ -81,6 +83,9 @@ export default class OpaqueImageView extends React.Component<Props, State> {

imageURL() {
const imageURL = this.props.imageURL
if (this.props.skipGemini) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@l2succes so here, we just serve the URL right back, as opposed to trying to process on-the-fly.

It's just a temp hack for now just to get something working.

imageAttachmentUrl = item.attachments[0].download_url
}
}
const hasImageAttachment = item.attachments.length > 0 && item.attachments[0].content_type === "image/jpeg"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

oo nice.

I'm going to update this for multiple attachments.

is_from_user
raw_text
created_at
id
Copy link
Contributor Author

Choose a reason for hiding this comment

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

wow, ok - I'm guessing this is what I was missing to get the fragment stuff working.

@mzikherman
Copy link
Contributor Author

Hmm, I fixed up the specs so I think this is mergable, but still has a Danger issue @orta any ideas?

@orta
Copy link
Contributor

orta commented Jun 27, 2017

It's because you're running from a fork - which we don't do on mobile repos. Can't deploy the PR nor run Danger without the secret env vars.

Peril will fix the danger issue, but not the latter, for now you should definitely add a CHANGELOG entry and consider it green.

@mzikherman
Copy link
Contributor Author

It's because you're running from a fork - which we don't do on mobile repos. Can't deploy the PR nor run Danger without the secret env vars.

Oo I didn't realize that, I can re-open from a pushed branch?

Or happy to just do the CHANGELOG and consider it 💚 and do that for next time.

@orta
Copy link
Contributor

orta commented Jun 27, 2017

I don't think you can change the repo remote - you can change branch, this is fine by me - whoever merges it should just do a quick check that everything other the PR updater, and Danger pass 👍

@mzikherman
Copy link
Contributor Author

Eh, in that case I'll do that next time, it might be nice to have this PR merged, vs a new PR, to preserve some of the comments.

@mzikherman
Copy link
Contributor Author

So I think this is mergable! And then we can merge artsy/metaphysics#680 to keep people in sync (people with in progress work will probably have to rebase once the Metaphysics schema hits staging).

@mzikherman
Copy link
Contributor Author

@orta mind taking a peek? I think @sarahscott might be out on vacay.

I have some polish and other stuff, but this basically has things in a working state.

Copy link
Contributor

@orta orta left a comment

Choose a reason for hiding this comment

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

This is good to merge, but only after undoing the change to a local metaphysics URL.

Yoga:
:path: "../node_modules/react-native/ReactCommon/yoga"
:path: ../node_modules/react-native/ReactCommon/yoga
Copy link
Contributor

Choose a reason for hiding this comment

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

This is such a constant battle :D

</Header>
{this.props.artworkPreview && <ArtworkPreviewContainer>{this.props.artworkPreview}</ArtworkPreviewContainer>}
<BodyText>{this.props.message.body.split("\n\nAbout")[0]}</BodyText>
{this.props.imagePreview && <ImagePreviewContainer>{this.props.imagePreview}</ImagePreviewContainer>}
<BodyText>{this.props.message.raw_text.split("\n\nAbout")[0]}</BodyText>
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this.props.message.raw_text.split("\n\nAbout")[0] worth verifying that the split will definitely work? Can't trust the server_too_ much ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So, this is actually going to change soon! Basically the sanitizing/formatting will be going upstream 🐟

Copy link
Contributor

Choose a reason for hiding this comment

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

👍 cool for now then

import OpaqueImageView from "../../../OpaqueImageView"

const Container = styled.View`
borderWidth: 1
Copy link
Contributor

Choose a reason for hiding this comment

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

kebab-case please @mzikherman

@@ -25,6 +25,8 @@ interface Props {
/** Any additional styling for the imageview */
style?: any

skipGemini?: boolean
Copy link
Contributor

Choose a reason for hiding this comment

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

Makes sense

}

renderMessage(message) {
renderMessage({ item }) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I forget about restructuring in params

@@ -9,6 +9,8 @@ if (Emission && Emission.useStagingEnvironment) {
metaphysicsURL = "https://metaphysics-production.artsy.net"
}

metaphysicsURL = "http://localhost:5001"
Copy link
Contributor

Choose a reason for hiding this comment

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

👍 - will need changing

@mzikherman
Copy link
Contributor Author

Alrighty, updated with the Metaphysics override removed!

@orta
Copy link
Contributor

orta commented Jun 27, 2017

OK - looks 👍

@orta orta merged commit d3b3449 into artsy:master Jun 27, 2017
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.

4 participants