From 0f30f17928e5a125ea51c8951648a62befb8514d Mon Sep 17 00:00:00 2001 From: Genadi888 Date: Fri, 18 Aug 2023 17:04:13 +0300 Subject: [PATCH] fixed window bug and changed way of sending the request for creating/editing a post --- src/api/posts.js | 2 -- src/views/car-pictures/infoWindow/infoWindow.js | 12 +++++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/api/posts.js b/src/api/posts.js index 324325f..bd9f1e8 100644 --- a/src/api/posts.js +++ b/src/api/posts.js @@ -24,7 +24,6 @@ export async function getPostById(id) { } export async function createPost(post) { - addEntryWithUserPointer(post, 'owner'); return api.post('/functions/createPost', post); } @@ -33,7 +32,6 @@ export async function deletePost(postId) { } export async function editPost(newPost) { - addEntryWithUserPointer(newPost, 'owner'); return api.post(`/functions/editPost`, newPost); } diff --git a/src/views/car-pictures/infoWindow/infoWindow.js b/src/views/car-pictures/infoWindow/infoWindow.js index 76ca39b..586f556 100644 --- a/src/views/car-pictures/infoWindow/infoWindow.js +++ b/src/views/car-pictures/infoWindow/infoWindow.js @@ -16,9 +16,15 @@ function showOrHideWindow(moreInfoWindow) { moreInfoWindow.style.opacity = 1; } else { //? here we clean up the publishComment section - moreInfoWindow.querySelector('textarea').value = ""; - const dataset = moreInfoWindow.querySelector('#publish-comment>.btn-primary').dataset; - Object.keys(dataset).forEach(key => delete dataset[key]); + + if (moreInfoWindow.querySelector('textarea')) { + moreInfoWindow.querySelector('textarea').value = ""; + } + + if (moreInfoWindow.querySelector('#publish-comment')) { + const dataset = moreInfoWindow.querySelector('#publish-comment>.btn-primary').dataset; + Object.keys(dataset).forEach(key => delete dataset[key]); + } moreInfoWindow.style['pointer-events'] = 'none'; moreInfoWindow.style.opacity = 0;