-
Notifications
You must be signed in to change notification settings - Fork 7
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
Refactor POIs so that Mobs can be displayed #131
Refactor POIs so that Mobs can be displayed #131
Conversation
Mucho cool! |
@WoH There's not. I never touched anything that wasn't related. If you want, you can think about this PR as "Refactor POIs so that Mobs can be displayed". If I had left things as they were, it would have been a mess. Nevertheless, plz review. I'd like to get this in. ;) |
@MajorBreakfast I would've liked to have the initial refractoring in a PR. |
I'd want @johartl to comment, the POI Cards are his baby. |
I'm going to merge this this evening unless there are objections to any of the things I changed. The code is clean and I tested all affected app parts thoroughly, so it should be fine. |
return sighting; | ||
} else if ('clusterId' in rawData) { | ||
const mob = new Mob(); | ||
return mob; |
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's the reason for returning an empty mob object here?
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.
Does the map already produce mobs? If so, what's the exact format of the event data?
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'm not sure if they already do. But the data should look like this PokemonGoers/PokeMap-2#32 (comment) which is exactly what our Mob
class represents.
The best thing you can probably do is const mob = Mob.fromObject(rawData);
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.
Well I just realized that you've removed the fromObject
method.
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 removed it from the model itself because it doesn't really belong in there.
<div class="title">PokeMob</div> | ||
<div class="description"> | ||
A lot of players seem to gather at this location!<br><br> | ||
Based on {{ poi.tweets.length }} tweet(s). |
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.
By the definition of a mob there should always be multiple tweets so I think you can replace tweet(s)
by tweets
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.
Okay. I'll change it.
@@ -10,4 +10,7 @@ | |||
</button> | |||
|
|||
<poke-poi-card #poiCard></poke-poi-card> | |||
|
|||
<button id="artificial-mob-button" |
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'm glad you added this button so I can test your functionality. But obviously that shouldn't end up in the final product. So I think either the button should be removed at all or somehow hidden such that it can only by used by developers.
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.
Let's leave it in for now, so that people can try it out. It's easy enough to remove later. It's for developers only, but triggering it through the console would be two cumbersome.
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 make sure neither mock data nor the button remain after all.
I like being able to test it that way though.
This would be beautiful to test with a mock websocket (I believe that's where we get those).
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.
How is triggering it through the console cumbersome? And even if it is, this functionality will only ever be used for testing purposes by developers. So it doesn't have to be easily accessible by everyone.
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.
@WoH What do you think?
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 can remove it immediately, e.g. by uncommenting it
- Or keep it for a while, e.g. remove it before we launch/map shows mobs
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.
Maybe show it only in dev Mode?
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.
Maybe set the style to display: none
and then anyone can still look for the element in the DOM using the developer console and make it visible.
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.
Now it is only shown in dev mode
Regarding the discussion about too many things in one PR. I mostly agree that all changes focus around the mob card with the exception of renaming PokeSighting, PokeAttack, PokeGender, PokeMob, and some more. Personally, I think you could have done this in a separate PR. |
} else { | ||
throw new Error('PokePOI cannot be identified as PokeSighting or PokeMob:\n' + JSON.stringify(pokePOI)); | ||
} | ||
function poiFromMapEventData(rawData: any) : POI { |
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.
no reason to use the function keyword
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 that TypeScript feature?
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.
Yes, and we are using it all over the place I think 😆 http://www.typescriptlang.org/docs/handbook/classes.html
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.
Compile error. Am I doing something wrong?
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.
Can you paste the error?
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.
TypeScript docu uses the keyword as well https://www.typescriptlang.org/docs/handbook/functions.html
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 class ends before the function definition, I didn't realiize this on github.
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.
Yep, exactly.
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.
I prefer the static method
<ion-row> | ||
<div id="slide-card" #slideCard @slide="slideState"> | ||
<!-- Sightings --> | ||
<div *ngIf="poi && poi.type == 'sighting' && pokemon"> |
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.
you could make use of the Elvis operator here: <div *ngIf="poi?.type == 'sighting' && pokemon">
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.
Elvis operator :) I'll change that
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 know that's something very Angular2 specific, but I think it is nice. Easy to understand, and makes these checks really concise.
Directions | ||
</button> | ||
<!-- Mobs --> | ||
<div *ngIf="poi && poi.type == 'mob'"> |
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.
See above
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.
Jep
timestamp: number; | ||
|
||
type = 'mob'; | ||
} | ||
|
||
export type PokeTweet = { | ||
export type MobTweet = { |
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.
If we extract this class to a separate file and call it Tweet
we can reuse it in other parts of the application. For instance, the sentiment analysis also returns an array of tweets and these are not related to mobs.
@johartl Plz update your review. |
Clear to merge? Any other wishes? |
@@ -25,4 +24,5 @@ export class ConfigService { | |||
} | |||
} | |||
|
|||
buildEnvironment = env.BUILD_ENV; |
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.
get buildEnvironment(): string {
return env.BUILD_ENV;
}
For consistency reasons this is better here maybe.
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. Even better: a method isDevelopEnvironment()
get isDevelopEnvironment(): boolean {
return env.BUILD_ENV === 'develop';
}
But that's just my personal preference.
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.
Done
WIP