Skip to content

Commit

Permalink
Allow hiding notes when shown in context of an overlay (fixes #5703)
Browse files Browse the repository at this point in the history
  • Loading branch information
westnordost committed Aug 14, 2024
1 parent b80551f commit b8d6260
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import de.westnordost.streetcomplete.data.osmnotes.edits.NoteEditAction
import de.westnordost.streetcomplete.data.osmnotes.edits.NoteEditsController
import de.westnordost.streetcomplete.data.osmnotes.edits.NotesWithEditsSource
import de.westnordost.streetcomplete.data.osmnotes.notequests.OsmNoteQuestController

Check failure on line 20 in app/src/main/java/de/westnordost/streetcomplete/quests/note_discussion/NoteDiscussionForm.kt

View workflow job for this annotation

GitHub Actions / Kotlin

Unused import
import de.westnordost.streetcomplete.data.osmnotes.notequests.OsmNoteQuestsHiddenController
import de.westnordost.streetcomplete.data.quest.OsmNoteQuestKey
import de.westnordost.streetcomplete.data.quest.QuestType
import de.westnordost.streetcomplete.data.user.User
Expand Down Expand Up @@ -51,7 +52,7 @@ class NoteDiscussionForm : AbstractQuestForm() {

private val noteSource: NotesWithEditsSource by inject()
private val noteEditsController: NoteEditsController by inject()
private val osmNoteQuestController: OsmNoteQuestController by inject()
private val osmNoteQuestsHiddenController: OsmNoteQuestsHiddenController by inject()
private val avatarsCacheDir: File by inject(named("AvatarsCacheDirectory"))

private val attachPhotoFragment get() =
Expand All @@ -72,7 +73,7 @@ class NoteDiscussionForm : AbstractQuestForm() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

val alreadyHidden = osmNoteQuestController.getVisible(noteId) == null
val alreadyHidden = osmNoteQuestsHiddenController.getHidden(noteId) != null
setButtonPanelAnswers(listOf(
if (alreadyHidden) {
AnswerItem(R.string.short_no_answer_on_button) { closeQuest() }
Expand Down Expand Up @@ -122,7 +123,7 @@ class NoteDiscussionForm : AbstractQuestForm() {

private fun hideQuest() {
viewLifecycleScope.launch {
withContext(Dispatchers.IO) { osmNoteQuestController.hide(noteId) }
withContext(Dispatchers.IO) { osmNoteQuestsHiddenController.hide(noteId) }
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ import de.westnordost.streetcomplete.data.osm.mapdata.Way
import de.westnordost.streetcomplete.data.osm.osmquests.OsmQuest
import de.westnordost.streetcomplete.data.osmnotes.edits.NotesWithEditsSource
import de.westnordost.streetcomplete.data.osmnotes.notequests.OsmNoteQuest
import de.westnordost.streetcomplete.data.osmnotes.notequests.OsmNoteQuestSource
import de.westnordost.streetcomplete.data.osmnotes.notequests.OsmNoteQuestsHiddenSource
import de.westnordost.streetcomplete.data.osmtracks.Trackpoint
import de.westnordost.streetcomplete.data.quest.OsmQuestKey
import de.westnordost.streetcomplete.data.quest.Quest
Expand Down Expand Up @@ -171,6 +173,7 @@ class MainFragment :
private val visibleQuestsSource: VisibleQuestsSource by inject()
private val mapDataWithEditsSource: MapDataWithEditsSource by inject()
private val notesSource: NotesWithEditsSource by inject()
private val noteQuestsHiddenSource: OsmNoteQuestsHiddenSource by inject()
private val locationAvailabilityReceiver: LocationAvailabilityReceiver by inject()
private val featureDictionary: Lazy<FeatureDictionary> by inject(named("FeatureDictionaryLazy"))
private val soundFx: SoundFx by inject()
Expand Down Expand Up @@ -1089,6 +1092,7 @@ class MainFragment :
notesSource
.getAll(BoundingBox(center, center).enlargedBy(1.2))
.firstOrNull { it.position.truncateTo5Decimals() == center.truncateTo5Decimals() }
?.takeIf { noteQuestsHiddenSource.getHidden(it.id) == null }
}
if (note != null) {
showQuestDetails(OsmNoteQuest(note.id, note.position))
Expand Down

0 comments on commit b8d6260

Please sign in to comment.