dsg
Copy This

Warning: file_get_contents(/home/u340524018/domains/agniaga.com/public_html/sub/u2/creator/post-view.js): Failed to open stream: No such file or directory in /home/u340524018/domains/agniaga.com/public_html/sub/u2/cp/inc.filehtml.php on line 319
// $(document).on('touchstart', '.media-single-post-content .swiper-wrapper', detectDoubleTapClosure((e) => {
//   const parent = e.closest('.media-post')
//   const postId = parent.getAttribute('data-post-id')
//   const isLiked = parent.getAttribute('data-is-liked') === 'true'

//   if (isLiked) {
//     return
//   }

//   togglePostLike(postId, true)
// }), {
//   passive: false
// })

$(document).on('page:beforein', '.page[data-name="post-view"]', async function (e) {
  var pathStore = store.getters.getPathData

  var postId = e.detail.route.params.id
  var query = e.detail.route.query

  let commentId;

  if (query && query.commentId) {
    commentId = query.commentId
  }

  if (!postId || postId === '-1') {
    return
  }

  let cachedData = null

  try {
    if (pathStore && pathStore.value[`/post/${postId}`]) {
      cachedData = pathStore.value[`/post/${postId}`]
    }
  } catch (error) {
    console.error('Error fetching cached data:', error)
  }

  if (!cachedData) {
    $('.loading-fullscreen.post-view').show()

    const post = await getPostById(postId)
    if (!post) {
      app.dialog.alert('Post not found', 'Error')
      return
    }

    store.dispatch('setPathData', {
      path: `/post/${postId}`,
      data: post,
    })

    cachedData = post
  } else {
    $('.loading-fullscreen.post-view').hide()
  }

  displayPost(cachedData)

  if (commentId) {
    $('.media-post-comment').click()
  }


  setTimeout(() => {
    // find .comment data-comment-id="${comment.id}" and animate it to glow#
    if (commentId) {
      const comment = $(`.comment[data-comment-id="${commentId}"]`)
      console.log('Comment:', comment);

      if (comment.length > 0) {
        comment.addClass('target-highlight')
        // Scroll to the comment
        document.querySelector(`.comment[data-comment-id="${commentId}"]`).scrollIntoView({
          behavior: 'smooth', // Optional, adds smooth scrolling
          block: 'start', // Aligns the element to the top of the view
          inline: 'nearest' // Aligns the element horizontally in the viewport
        });

      }

      setTimeout(() => {
        comment.removeClass('target-highlight')
      }, 3000)
    }
  }, 2000)
})
Array
(
)
Add JS Function Name