MCPcopy Create free account
hub / github.com/facebook/Rapid / updateChangeset

Function updateChangeset

modules/ui/commit.js:666–726  ·  view source on GitHub ↗
(changed, onInput)

Source from the content-addressed store, hash-verified

664
665
666 function updateChangeset(changed, onInput) {
667 let tags = Object.assign({}, uploader.changeset.tags); // shallow copy
668
669 Object.keys(changed).forEach(function(k) {
670 let v = changed[k];
671 k = context.cleanTagKey(k);
672 if (readOnlyTags.indexOf(k) !== -1) return;
673
674 if (v === undefined) {
675 delete tags[k];
676 } else if (onInput) {
677 tags[k] = v;
678 } else {
679 tags[k] = context.cleanTagValue(v);
680 }
681 });
682
683 if (!onInput) {
684 // when changing the comment, override hashtags with any found in comment.
685 const commentOnly = changed.hasOwnProperty('comment') && (changed.comment !== '');
686 const arr = findHashtags(tags, commentOnly);
687 if (arr.length) {
688 tags.hashtags = context.cleanTagValue(arr.join(';'));
689 storage.setItem('hashtags', tags.hashtags);
690 } else {
691 delete tags.hashtags;
692 storage.removeItem('hashtags');
693 }
694 }
695
696 // always update userdetails, just in case user reauthenticates as someone else
697 if (_userDetails && _userDetails.changesets_count !== undefined) {
698 let changesetsCount = parseInt(_userDetails.changesets_count, 10) + 1; // iD#4283
699 tags.changesets_count = String(changesetsCount);
700
701 // first 100 edits - new user
702 if (changesetsCount <= 100) {
703 let s;
704 s = storage.getItem('walkthrough_completed');
705 if (s) {
706 tags['ideditor:walkthrough_completed'] = s;
707 }
708
709 s = storage.getItem('walkthrough_progress');
710 if (s) {
711 tags['ideditor:walkthrough_progress'] = s;
712 }
713
714 s = storage.getItem('walkthrough_started');
715 if (s) {
716 tags['ideditor:walkthrough_started'] = s;
717 }
718 }
719 } else {
720 delete tags.changesets_count;
721 }
722
723 if (!deepEqual(uploader.changeset.tags, tags)) {

Callers 2

toggleRequestReviewFunction · 0.85
changeTagsFunction · 0.85

Calls 8

findHashtagsFunction · 0.85
keysMethod · 0.45
cleanTagKeyMethod · 0.45
cleanTagValueMethod · 0.45
setItemMethod · 0.45
removeItemMethod · 0.45
getItemMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected