-
Notifications
You must be signed in to change notification settings - Fork 32
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
fix: bug when the name of subcategory is empty #263
fix: bug when the name of subcategory is empty #263
Conversation
2e3a962
to
f03e289
Compare
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've asked Moiz to confirm the default string for us. Meanwhile, I believe it would be wise to minimize the usage of topic.name
to zero, as it could potentially cause issues in other areas as well.
Regarding an alternative approach, using something like this codesnippet to fetch the topic title from one common place seems like a good idea. Thoughts?
f03e289
to
bfd0507
Compare
@HamzaIsrar12 I changed where the topic name located. Check it please. Waiting for Moiz's confirmation... |
fun getTopicName(): String { | ||
return name.ifEmpty { stringResource(id = R.string.discussion_unnamed_subcategory) } | ||
} |
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.
Not sure if the UI layer code can be stored in the domain model.
Is there any possibility to move it to the UI layer?
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.
Continuing your thought process, @volodymyr-chekyrta, perhaps we can update it at the repository level.
suspend fun getCourseTopics(courseId: String): List<Topic> {
val topicsData = api.getCourseTopics(courseId).mapToDomain()
// Fetch default name
val defaultTopicName = resourceManager.getString(R.string.discussion_unnamed_subcategory)
currentCourseId = courseId
topics.clear()
topics.addAll(topicsData.nonCoursewareTopics)
topicsData.coursewareTopics.forEach {
topics.add(it)
if (it.children.isNotEmpty()) {
topics.addAll(it.children)
}
}
// New Code
topics.forEachIndexed { index, topic ->
if (topic.name.isBlank()) {
topics[index] = topic.copy(name = defaultTopicName)
}
}
// End
return topics.toList()
}
Thoughts?
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
@dixidroid Moiz has approved the usage of "Unnamed subcategory". 👍🏻 |
bfd0507
to
b72f65b
Compare
fixed a bug when the name of subcategory was empty in Discussions