From c841823bdad60c641582261dc49a3e963bbc6d7d Mon Sep 17 00:00:00 2001 From: Rotimi Best Date: Sun, 3 Aug 2025 17:59:21 +0100 Subject: [PATCH] fix: prevent duplicate comment channel subscriptions and improve translation check --- .../Materials/components/Comments.svelte | 28 +++++++++++-------- .../Materials/components/ComponentNote.svelte | 8 ++++-- .../Course/components/Lesson/store/lessons.ts | 3 ++ 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/apps/dashboard/src/lib/components/Course/components/Lesson/Materials/components/Comments.svelte b/apps/dashboard/src/lib/components/Course/components/Lesson/Materials/components/Comments.svelte index e0f1f8ce..7a33c3b3 100644 --- a/apps/dashboard/src/lib/components/Course/components/Lesson/Materials/components/Comments.svelte +++ b/apps/dashboard/src/lib/components/Course/components/Lesson/Materials/components/Comments.svelte @@ -1,6 +1,9 @@ diff --git a/apps/dashboard/src/lib/components/Course/components/Lesson/Materials/components/ComponentNote.svelte b/apps/dashboard/src/lib/components/Course/components/Lesson/Materials/components/ComponentNote.svelte index f2e2dd53..a93ef636 100644 --- a/apps/dashboard/src/lib/components/Course/components/Lesson/Materials/components/ComponentNote.svelte +++ b/apps/dashboard/src/lib/components/Course/components/Lesson/Materials/components/ComponentNote.svelte @@ -16,7 +16,9 @@ $lesson.locale ); $: hasAtLeastOneTranslation = Object.values($lessonByTranslation[lessonId] || {}).some( - (c) => !!c.length + (content) => { + return content && !!content.length; + } ); @@ -29,8 +31,8 @@ {:else if hasAtLeastOneTranslation} -
-

+
+

{$t('course.navItem.lessons.materials.no_translation')}

diff --git a/apps/dashboard/src/lib/components/Course/components/Lesson/store/lessons.ts b/apps/dashboard/src/lib/components/Course/components/Lesson/store/lessons.ts index 6352d9bb..4a40f3f8 100644 --- a/apps/dashboard/src/lib/components/Course/components/Lesson/store/lessons.ts +++ b/apps/dashboard/src/lib/components/Course/components/Lesson/store/lessons.ts @@ -10,6 +10,7 @@ import { } from '$lib/utils/services/courses'; import { LOCALE } from '$lib/utils/types'; +import type { RealtimeChannel } from '@supabase/supabase-js'; import { lessonValidation } from '$lib/utils/functions/validator'; import { snackbar } from '$lib/components/Snackbar/store'; import { writable } from 'svelte/store'; @@ -23,6 +24,8 @@ export const lessons: Writable = writable([]); export const lessonSections: Writable = writable([]); +export const lessonCommentsChannel: Writable = writable(); + export const lesson = writable({ id: null, locale: LOCALE.EN,