Let's open up our ReACT application and make a little change.
This list of comments right here.
Get going to find my code.
Editor of On the client directory inside there then our see and remember all the comments are being
rendered inside of a comment list deer's comment list inside of comment list we iterate over all the
different comments and produce an ally for each one.
So we probably want to take a look at the status of every comment and if it is equal to rejected or
pending we don't really want to show this ally.
We probably want to show something else or please least change out the content inside of it.
So let's try putting together just a simple series of IF statements I can declare a new variable up
here called content.
Let's then say if comment dot status is equal to approved then content can be the actual comments content
if comment dot status is equal to ending lovely content be.
This comment is awaiting moderation and then if comment dot status is rejected content can instead be
this comment has been rejected and of course we could refactor these three statements into a switch
statement instead.
If you would like I'll leave that up to you.
Then finally rather than showing come incontinence side of here I'll display whatever the value of content
is well put in content like so let's save this.
I'm gonna flip back over and you'll notice that the comment that had the word orange inside of it has
now been replaced with.
This comment has been rejected.
Very good.
I would like to also test out the case in which we do not undergo moderation immediately.
So this will be a case in which maybe it takes a human intervention say something like five minutes
10 minutes 20 minutes to actually come in and moderate any given comment.
So if we do not get that status updated from pending over to rejected or approved then we should instead
see this comment is a waiting moderation to simulate that case.
We can go back over to our terminal and just shut down the moderation service entirely.
I'll go back or my journal.
I'm going to find a window that is running my moderation service.
I'm going to stop that operation and I'll go and create a new comment
I'll submit it.
Now that comment is gonna be stuck in the pending state.
There's nothing to actually approve it and move it forward so we can refresh and we should see this
comment is awaiting moderation.
Awesome OK.
So this looks pretty good but I want to point out that there kind of is a downside to our application
right now.
We just turned off the app moderation service.
If we start up the moderation service again so flip back over my terminal and start it back up.
Well now the moderation service is running but the broker or event bus tried to send an event over.
While the moderation service was down so we're now in a scenario where we had a temporary interruption
to our moderation service but we lost events in that window and so now our entire application is kind
of out of sync so to speak.
We don't have any way to kind of fast forward and get those missing events back over to our moderation
service.
So maybe that's something we should try to at least think about and figure out some way to fix.
Let's take a pause right here and see if we can't figure out some way of dealing with that in just a
moment.