feat: set ordinal for tweets correctly

(maybe do this in backend instead #improvement)
This commit is contained in:
overflowerror 2021-08-21 20:32:22 +02:00
parent bed63fc923
commit 046a9fb12a
2 changed files with 6 additions and 0 deletions

View file

@ -11,6 +11,7 @@ type Tweet = {
status: TweetStatus,
tweet_id: number|null,
error: string|null
ordinal: number
}
export default Tweet

View file

@ -168,6 +168,7 @@ const Index: FunctionComponent<ThreadFormProps> = (
text: "",
status: TweetStatus.SCHEDULED,
tweet_id: null,
ordinal: 0,
error: null
})
setThread({
@ -196,6 +197,10 @@ const Index: FunctionComponent<ThreadFormProps> = (
setError("Tweets can't be longer than 280 characters!")
return
}
thread.tweets.forEach((tweet, index) => {
tweet.ordinal = index
})
setError(null)
onSubmit(thread)
}} color="primary">