{"version":3,"file":"CommentSection-ClFb7E4o.mjs","names":[],"sources":["../src/components/display/comments/CommentSection.vue","../src/components/display/comments/CommentSection.vue"],"sourcesContent":["<template>\n  <section v-show=\"displayCommentSection\" class=\"module-box\">\n    <div class=\"d-flex align-items-center\">\n      <component \n        :is=\"inStudio? 'div':'h3'\" \n        :class=\"inStudio? 'm-1 fw-bold':'mb-0 me-2'\">{{ t(\"Podcast's comments\") }}</component>\n      <button\n        :title=\"t('Refresh')\"\n        class=\"btn btn-transparent\"\n        @click=\"reload = !reload\"\n      >\n        <RefreshIcon />\n      </button>\n    </div>\n    <CommentInput\n      v-if=\"canPostComment\"\n      :podcast=\"podcast\"\n      @new-comment=\"newComment\"\n    />\n    <CommentList\n      v-model:nb-comments=\"nbComments\"\n      :class=\"inStudio? 'mt-2':'mt-5'\"\n      :podcast=\"podcast\"\n      :is-flat-list=\"inStudio\"\n      :reload=\"reload\"\n      :config=\"configPodcast\"\n      :event-to-handle=\"eventToHandle\"\n      :state-filter=\"stateFilter\"\n    />\n  </section>\n</template>\n\n<script setup lang=\"ts\">\nimport RefreshIcon from \"vue-material-design-icons/Refresh.vue\";\nimport { Podcast } from \"@/stores/class/general/podcast\";\nimport { computed, defineAsyncComponent, onBeforeMount, ref, Ref, watch } from \"vue\";\nimport { useCommentStore } from \"../../../stores/CommentStore\";\nimport { useAuthStore } from \"../../../stores/AuthStore\";\nimport {\n  CommentMessage,\n  CommentsConfig,\n} from \"@/stores/class/config/commentsConfig\";\nimport { CommentPodcast } from \"@/stores/class/general/comment\";\nimport { useI18n } from \"vue-i18n\";\nconst CommentList = defineAsyncComponent(() => import(\"./CommentList.vue\"));\nconst CommentInput = defineAsyncComponent(() => import(\"./CommentInput.vue\"));\n\n//Props \nconst props = defineProps({\n  podcast: { default: undefined, type: Object as () => Podcast },\n  inStudio: { default: false, type: Boolean },\n  stateFilter: { default: \"\", type: String },\n})\n\n//Emits\nconst emit = defineEmits([\"commentReceived\"]);\n\n//Data \nconst reload = ref(false);\nconst configPodcast: Ref<CommentsConfig | undefined> = ref(undefined);\nconst nbComments = ref(0);\nconst eventToHandle: Ref<CommentMessage | undefined> = ref(undefined);\n\n//Composables\nconst { t } = useI18n();\nconst commentStore = useCommentStore();\nconst authStore = useAuthStore();\n\n\n//Computed\nconst displayCommentSection = computed(() => canPostComment.value || nbComments.value > 0);\nconst canPostComment = computed(() => {\n  return commentStore.getCanPostComment(\n    configPodcast.value,\n    props.podcast,\n    undefined !== authStore.authOrgaId,\n  );\n});\nconst eventActive = computed(() =>  undefined !== props.podcast?.conferenceId);\n\n\n//Watch\nwatch(()=>commentStore.commentEventToHandle, async () => {\n  if (\n    !commentStore.commentEventToHandle.length ||\n    commentStore.commentPodcastId !== props.podcast?.podcastId\n  ){\n    return;\n  }\n  eventToHandle.value = commentStore.commentEventToHandle[0];\n  commentStore.commentEventHandled();\n  emit('commentReceived');\n}, {deep: true});\n\n\nonBeforeMount(()=>fetchPodcastCommentsConfig())\n\n\n//Methods\nasync function fetchPodcastCommentsConfig() {\n  if (!props.podcast?.podcastId) {\n    return;\n  }\n  configPodcast.value = await commentStore.getCommentsConfig(props.podcast);\n  if (!eventActive.value) {\n    return;\n  }\n  initLiveComments();\n}\nasync function initLiveComments(): Promise<void> {\n  if (!props.podcast?.podcastId || !props.podcast?.organisation.id) {\n    return;\n  }\n  if (!commentStore.commentInitialized) {\n    await commentStore.initialize();\n  }\n  await commentStore.initComments(\n    props.podcast.podcastId,\n    props.podcast.organisation.id,\n  );\n}\nfunction newComment(comment: CommentPodcast) {\n  if (eventActive.value) {\n    return;\n  }\n  eventToHandle.value = { type: \"CREATE\", comment: comment };\n}\n</script>\n","<template>\n  <section v-show=\"displayCommentSection\" class=\"module-box\">\n    <div class=\"d-flex align-items-center\">\n      <component \n        :is=\"inStudio? 'div':'h3'\" \n        :class=\"inStudio? 'm-1 fw-bold':'mb-0 me-2'\">{{ t(\"Podcast's comments\") }}</component>\n      <button\n        :title=\"t('Refresh')\"\n        class=\"btn btn-transparent\"\n        @click=\"reload = !reload\"\n      >\n        <RefreshIcon />\n      </button>\n    </div>\n    <CommentInput\n      v-if=\"canPostComment\"\n      :podcast=\"podcast\"\n      @new-comment=\"newComment\"\n    />\n    <CommentList\n      v-model:nb-comments=\"nbComments\"\n      :class=\"inStudio? 'mt-2':'mt-5'\"\n      :podcast=\"podcast\"\n      :is-flat-list=\"inStudio\"\n      :reload=\"reload\"\n      :config=\"configPodcast\"\n      :event-to-handle=\"eventToHandle\"\n      :state-filter=\"stateFilter\"\n    />\n  </section>\n</template>\n\n<script setup lang=\"ts\">\nimport RefreshIcon from \"vue-material-design-icons/Refresh.vue\";\nimport { Podcast } from \"@/stores/class/general/podcast\";\nimport { computed, defineAsyncComponent, onBeforeMount, ref, Ref, watch } from \"vue\";\nimport { useCommentStore } from \"../../../stores/CommentStore\";\nimport { useAuthStore } from \"../../../stores/AuthStore\";\nimport {\n  CommentMessage,\n  CommentsConfig,\n} from \"@/stores/class/config/commentsConfig\";\nimport { CommentPodcast } from \"@/stores/class/general/comment\";\nimport { useI18n } from \"vue-i18n\";\nconst CommentList = defineAsyncComponent(() => import(\"./CommentList.vue\"));\nconst CommentInput = defineAsyncComponent(() => import(\"./CommentInput.vue\"));\n\n//Props \nconst props = defineProps({\n  podcast: { default: undefined, type: Object as () => Podcast },\n  inStudio: { default: false, type: Boolean },\n  stateFilter: { default: \"\", type: String },\n})\n\n//Emits\nconst emit = defineEmits([\"commentReceived\"]);\n\n//Data \nconst reload = ref(false);\nconst configPodcast: Ref<CommentsConfig | undefined> = ref(undefined);\nconst nbComments = ref(0);\nconst eventToHandle: Ref<CommentMessage | undefined> = ref(undefined);\n\n//Composables\nconst { t } = useI18n();\nconst commentStore = useCommentStore();\nconst authStore = useAuthStore();\n\n\n//Computed\nconst displayCommentSection = computed(() => canPostComment.value || nbComments.value > 0);\nconst canPostComment = computed(() => {\n  return commentStore.getCanPostComment(\n    configPodcast.value,\n    props.podcast,\n    undefined !== authStore.authOrgaId,\n  );\n});\nconst eventActive = computed(() =>  undefined !== props.podcast?.conferenceId);\n\n\n//Watch\nwatch(()=>commentStore.commentEventToHandle, async () => {\n  if (\n    !commentStore.commentEventToHandle.length ||\n    commentStore.commentPodcastId !== props.podcast?.podcastId\n  ){\n    return;\n  }\n  eventToHandle.value = commentStore.commentEventToHandle[0];\n  commentStore.commentEventHandled();\n  emit('commentReceived');\n}, {deep: true});\n\n\nonBeforeMount(()=>fetchPodcastCommentsConfig())\n\n\n//Methods\nasync function fetchPodcastCommentsConfig() {\n  if (!props.podcast?.podcastId) {\n    return;\n  }\n  configPodcast.value = await commentStore.getCommentsConfig(props.podcast);\n  if (!eventActive.value) {\n    return;\n  }\n  initLiveComments();\n}\nasync function initLiveComments(): Promise<void> {\n  if (!props.podcast?.podcastId || !props.podcast?.organisation.id) {\n    return;\n  }\n  if (!commentStore.commentInitialized) {\n    await commentStore.initialize();\n  }\n  await commentStore.initComments(\n    props.podcast.podcastId,\n    props.podcast.organisation.id,\n  );\n}\nfunction newComment(comment: CommentPodcast) {\n  if (eventActive.value) {\n    return;\n  }\n  eventToHandle.value = { type: \"CREATE\", comment: comment };\n}\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;EA4CA,MAAM,cAAc,2BAA2B,OAAO,6BAAoB;EAC1E,MAAM,eAAe,2BAA2B,OAAO,8BAAqB;EAG5E,MAAM,QAAQ;EAOd,MAAM,OAAO;EAGb,MAAM,SAAS,IAAI,KAAK;EACxB,MAAM,gBAAiD,IAAI,KAAA,CAAS;EACpE,MAAM,aAAa,IAAI,CAAC;EACxB,MAAM,gBAAiD,IAAI,KAAA,CAAS;EAGpE,MAAM,EAAE,MAAM,QAAQ;EACtB,MAAM,eAAe,gBAAgB;EACrC,MAAM,YAAY,aAAa;EAI/B,MAAM,wBAAwB,eAAe,eAAe,SAAS,WAAW,QAAQ,CAAC;EACzF,MAAM,iBAAiB,eAAe;GACpC,OAAO,aAAa,kBAClB,cAAc,OACd,MAAM,S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