Skip to content
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

feat: Order feedback by date #2261

Merged
merged 16 commits into from
Jun 27, 2019
Merged

feat: Order feedback by date #2261

merged 16 commits into from
Jun 27, 2019

Conversation

atm1504
Copy link
Member

@atm1504 atm1504 commented Jun 12, 2019

Fixes #2023 #1453

Changes:
The feedback is now ordered in a way such that, if the user has feedback, then it gets displayed at the top and the rests are ordered by the newest first.

Screenshots for the change:
WhatsApp Image 2019-06-13 at 12 16 25 AM

Apk:
app-fdroid-debug.apk.zip

@auto-label auto-label bot added the feature label Jun 12, 2019
@atm1504
Copy link
Member Author

atm1504 commented Jun 19, 2019

@arundhati24 @batbrain7 @iamareebjamal please review it.

@atm1504
Copy link
Member Author

atm1504 commented Jun 22, 2019

@liveHarshit can u please review it. So that @iamareebjamal can finalize it easily.

feedback.avatar = item.avatar
feedback.timestamp = item.timestamp
feedback.feedback = item.feedback
arrangedFeedbackList.add(feedback)
Copy link
Member

Choose a reason for hiding this comment

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

remove duplication

@atm1504
Copy link
Member Author

atm1504 commented Jun 23, 2019

@liveHarshit please review now. : )

feedback.userName = item.userName
feedback.avatar = item.avatar
feedback.timestamp = item.timestamp
feedback.feedback = item.feedback
Copy link
Member

Choose a reason for hiding this comment

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

Why are you copying it?

Copy link
Member Author

Choose a reason for hiding this comment

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

Currently what we have is that we get a response of the feedback in the order of newest at the top. But what we want is that, if the user logged in has given any feedback, then it should come at the top irrespective of the time he gave that feedback. After user feedback is shown, we need to show the rest of the feedbacks in the order with the newest at the top. So, to arrange the list in such an order, I am keeping a separate list of those items and showing these data, with actually affecting the server response directly.

Copy link
Member

Choose a reason for hiding this comment

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

Why are you creating a new feedback object and copying the same data in it?

Copy link
Member Author

Choose a reason for hiding this comment

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

The actual feedback response has many different kinds of data, we don't need those data to display or even to iterate any operation. So, I made a feedback object, which can copy the response that we need, instead of copying all the data.

Copy link
Member

Choose a reason for hiding this comment

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

If you don't create a new object, will there be any problem?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, what I can do is that I can create the object only once and reuse it every time.

Copy link
Member

@iamareebjamal iamareebjamal Jun 23, 2019

Choose a reason for hiding this comment

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

Why do you even want to create an object?

Copy link
Member Author

Choose a reason for hiding this comment

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

We don't need. I understood what u wanted to say. Updating the pr accordingly.

private fun arrangeFeedbacks() {
arrangedFeedbackList.clear()
feedbackResponse.feedbackList.forEach { item ->
if (item.email == PrefManager.getStringSet(Constant.SAVED_EMAIL)?.iterator()?.next()) {
Copy link
Member

Choose a reason for hiding this comment

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

PrefManager.getStringSet(Constant.SAVED_EMAIL)?.iterator()?.next() what?

Copy link
Member Author

Choose a reason for hiding this comment

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

PrefManager.getStringSet(Constant.SAVED_EMAIL)?.iterator()?.next() what?

This method has been used throughout the app while extracting email from the PrefManager. So, I used it else I would have simply used PrefManager.getString(Constant.SAVED_EMAIL,"")

Copy link
Member

Choose a reason for hiding this comment

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

Use yours

Copy link
Member Author

@atm1504 atm1504 Jun 25, 2019

Choose a reason for hiding this comment

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

@iamareebjamal the app is crashing if I use the getString method in prefmanger to extract the email, but it is working if I use getStringSet. Probably that's the reason getStringSet has been used throughout the app.

Copy link
Member

Choose a reason for hiding this comment

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

OK, revert but it is very stupid

Copy link
Member Author

Choose a reason for hiding this comment

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

Already reverted in the latest update.

@atm1504
Copy link
Member Author

atm1504 commented Jun 25, 2019

@iamareebjamal please review it now.

@@ -26,6 +30,7 @@ class FeedbackAdapter(
RecyclerView.Adapter<FeedbackViewHolder>(), FeedbackViewHolder.ClickListener {

private val clickListener: FeedbackViewHolder.ClickListener = this
var arrangedFeedbackList: ArrayList<Feedback> = ArrayList()
Copy link
Member

Choose a reason for hiding this comment

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

Where are you reassigning the variable? From which external class are you accessing the variable?

Seems I have to repeat the same review again and again. I will not review again unless you learn from past reviews and stop making same mistakes again and again

Copy link
Member Author

Choose a reason for hiding this comment

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

Where are you reassigning the variable? From which external class are you accessing the variable?

Seems I have to repeat the same review again and again. I will not review again unless you learn from past reviews and stop making same mistakes again and again

Sorry for the inconvenience caused. I will definitely take care of now and not give any other chance for such mistakes.
I have updated it. Also, I have changed it to getStringSet, else the app is crashing. During the successful login, the email id is saved using StringSet. So we have to use stringSet to retrieve the data.

}
}

var reverseResponse = feedbackResponse.feedbackList.asReversed()
Copy link
Member

Choose a reason for hiding this comment

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

Where are you reassigning this? I told you last time to check before submitting PRs for review

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated

@atm1504
Copy link
Member Author

atm1504 commented Jun 25, 2019

@iamareebjamal please review it. I have changed all var to val wherever possible. Also, I went through the code once again to look for such mistakes.

@atm1504
Copy link
Member Author

atm1504 commented Jun 27, 2019

@iamareebjamal please review it now.

@atm1504
Copy link
Member Author

atm1504 commented Jun 27, 2019

@iamareebjamal please review it.

@iamareebjamal iamareebjamal merged commit 51bb133 into fossasia:development Jun 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feedback should be ordered by newest on top
3 participants