-
Notifications
You must be signed in to change notification settings - Fork 78
@sarahscott => [Messaging] WIP on updating messages connection/fragment #630
Conversation
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", |
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.
Will undo once Metaphysics is merged...
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.
@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
650c510
to
870b9de
Compare
@@ -61,14 +61,6 @@ const ComposerContainer = styled.View` | |||
` | |||
|
|||
export class Conversation extends React.Component<RelayProps, any> { | |||
isFromUser(message) { |
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.
👋
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.
🙌
src/lib/relay/config.tsx
Outdated
@@ -9,6 +9,8 @@ if (Emission && Emission.useStagingEnvironment) { | |||
metaphysicsURL = "https://metaphysics-production.artsy.net" | |||
} | |||
|
|||
metaphysicsURL = "http://localhost:5001" |
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.
Once Metaphysics is merged, will undo.
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.
👍 - will need changing
c28efa3
to
0aea698
Compare
So, I have this sorta working, w/o Relay fragments :( (image previews, Where I'm at is that replacing the explicit queries with 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 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, |
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.
In ListView
s and FlatList
s, every item has to have a unique key
. Usually we just use the id
or __id
of the object; whichever one is numeric.
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.
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 |
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.
🔑
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.
🔒
So this now runs locally for me, although I haven't tried the |
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", |
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.
@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 |
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.
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
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.
Make sure to add stylefmt too so that it's automated: #599
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.
kebab-case
please @mzikherman
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.
Actually, don't bother - I will get this right now: https://twitter.com/rauchg/status/879752736467591168
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.
in a separate PR
@@ -25,6 +25,8 @@ interface Props { | |||
/** Any additional styling for the imageview */ | |||
style?: any | |||
|
|||
skipGemini?: boolean |
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.
what does skipGemini
mean?
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.
Ah sorry, didn't know we had a service named gemini 😅
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.
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.
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.
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) { |
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.
@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.
src/lib/Containers/Conversation.tsx
Outdated
imageAttachmentUrl = item.attachments[0].download_url | ||
} | ||
} | ||
const hasImageAttachment = item.attachments.length > 0 && item.attachments[0].content_type === "image/jpeg" |
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.
oo nice.
I'm going to update this for multiple attachments.
src/lib/Containers/Conversation.tsx
Outdated
is_from_user | ||
raw_text | ||
created_at | ||
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.
wow, ok - I'm guessing this is what I was missing to get the fragment
stuff working.
Hmm, I fixed up the specs so I think this is mergable, but still has a Danger issue @orta any ideas? |
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. |
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. |
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 👍 |
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. |
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). |
@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. |
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 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 |
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 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> |
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.
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 ;)
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.
So, this is actually going to change soon! Basically the sanitizing/formatting will be going upstream 🐟
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.
👍 cool for now then
import OpaqueImageView from "../../../OpaqueImageView" | ||
|
||
const Container = styled.View` | ||
borderWidth: 1 |
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.
kebab-case
please @mzikherman
@@ -25,6 +25,8 @@ interface Props { | |||
/** Any additional styling for the imageview */ | |||
style?: any | |||
|
|||
skipGemini?: boolean |
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.
Makes sense
} | ||
|
||
renderMessage(message) { | ||
renderMessage({ item }) { |
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 forget about restructuring in params
src/lib/relay/config.tsx
Outdated
@@ -9,6 +9,8 @@ if (Emission && Emission.useStagingEnvironment) { | |||
metaphysicsURL = "https://metaphysics-production.artsy.net" | |||
} | |||
|
|||
metaphysicsURL = "http://localhost:5001" |
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.
👍 - will need changing
Alrighty, updated with the Metaphysics override removed! |
OK - looks 👍 |
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 ofsnippet
), and we now haveis_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.