Skip to content

Commit

Permalink
save handler
Browse files Browse the repository at this point in the history
  • Loading branch information
zbycz committed Oct 14, 2024
1 parent cb6e41f commit 1470fc9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,7 @@ const SaveButton = () => {
const handleSave = useGetHandleSave();

return (
<Button
onClick={handleSave}
color="primary"
variant="contained"
startIcon={loading && <CircularProgress size={20} color={'secondary'} />}
disabled={loading}
>
<Button onClick={handleSave} color="primary" variant="contained">
{loggedIn
? tags.cancelled
? t('editdialog.save_button_delete')
Expand Down
12 changes: 4 additions & 8 deletions src/components/FeaturePanel/EditDialog/useGetHandleSave.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,13 @@ export const useGetHandleSave = () => {
setIsSaving,
location,
comment,
tags: { tags, typeTag, tmpNewTag, cancelled },
tags: { tags, cancelled },
} = useEditContext();

return () => {
const tagsWithType = typeTag
? { [typeTag.key]: typeTag.value, ...tags }
: tags;
const allTags = { ...tagsWithType, ...tmpNewTag }; // we need to send also unsubmitted new tag
const noteText = createNoteText(
feature,
allTags,
tags,
cancelled,
location,
comment,
Expand All @@ -39,8 +35,8 @@ export const useGetHandleSave = () => {
setIsSaving(true);
const promise = loggedIn
? feature.point
? addOsmFeature(feature, comment, allTags)
: editOsmFeature(feature, comment, allTags, cancelled)
? addOsmFeature(feature, comment, tags)
: editOsmFeature(feature, comment, tags, cancelled)
: insertOsmNote(feature.center, noteText);

promise.then(setSuccessInfo, (err) => {
Expand Down

0 comments on commit 1470fc9

Please sign in to comment.