Changeset 18443 in josm


Ignore:
Timestamp:
2022-05-10T18:42:34+02:00 (2 years ago)
Author:
taylor.smock
Message:

Fix #17288: Notes progress bar shows no progress (patch by gaben, modified)

The patch provided by gaben was modified to only count modified notes for
the progress bar and count. Technically speaking, this is a little less
efficient, as the modified notes will have to iterate through comments
twice instead of once. This should not be noticeable to end users, as
they should not (generally speaking) be closing enough notes for this
to be an issue.

UploadNotesTask now has a test (not by gaben) to check for correctness.

Location:
trunk
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/upload/UploadNotesTask.java

    r16438 r18443  
    55
    66import java.io.IOException;
     7import java.util.Collection;
    78import java.util.HashMap;
    89import java.util.Map;
     10import java.util.Optional;
    911import java.util.stream.Collectors;
    1012
     
    6466        @Override
    6567        protected void realRun() throws SAXException, IOException, OsmTransferException {
    66             ProgressMonitor monitor = progressMonitor.createSubTaskMonitor(ProgressMonitor.ALL_TICKS, false);
    6768            OsmApi api = OsmApi.getOsmApi();
    68             for (Note note : noteData.getNotes()) {
     69            final Collection<Note> modifiedNotes = noteData.getNotes().stream()
     70                    .filter(note -> Optional.ofNullable(note.getLastComment()).map(NoteComment::isNew).orElse(false))
     71                    .collect(Collectors.toList());
     72            getProgressMonitor().setTicksCount(modifiedNotes.size());
     73            for (Note note : modifiedNotes) {
     74                getProgressMonitor().setCustomText(tr("Uploading notes {0}/{1}", getProgressMonitor().getTicks(),
     75                        getProgressMonitor().getTicksCount()));
    6976                if (isCanceled) {
    7077                    Logging.info("Note upload interrupted by user");
     
    7481                    if (comment.isNew()) {
    7582                        Logging.debug("found note change to upload");
    76                         processNoteComment(monitor, api, note, comment);
     83                        processNoteComment(getProgressMonitor(), api, note, comment);
    7784                    }
    7885                }
     86                getProgressMonitor().worked(1);
    7987            }
    8088        }
Note: See TracChangeset for help on using the changeset viewer.