From 64a058ebc878b4f63bd0371447b5649f023a7259 Mon Sep 17 00:00:00 2001 From: Rotimi Best Date: Sun, 29 Oct 2023 12:49:10 +0000 Subject: [PATCH] CLASSROOMIO-T-216: Fix loading course multiple times --- README.md | 1 - package.json | 6 ------ .../components/CourseContainer/index.svelte | 7 +++++-- .../components/CourseLandingPage/index.svelte | 2 -- src/lib/utils/services/sendgrid.ts | 18 ------------------ src/routes/+layout.svelte | 4 +--- svelte.config.js | 9 +-------- 7 files changed, 7 insertions(+), 40 deletions(-) delete mode 100644 src/lib/utils/services/sendgrid.ts diff --git a/README.md b/README.md index c4d57c9b..f599c6e2 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,6 @@ Note: Make sure you are using Node 18 ```env PUBLIC_SUPABASE_ANON_KEY= PUBLIC_SUPABASE_URL= -NETLIFY_API_KEY= OPENAI_API_KEY= CLOUDFLARE_TOKEN_VALUE= CLOUDFLARE_ACCESS_KEY= diff --git a/package.json b/package.json index a10354e8..a2b31eca 100644 --- a/package.json +++ b/package.json @@ -15,17 +15,13 @@ "dependencies": { "@aws-sdk/client-s3": "^3.386.0", "@carbon/charts-svelte": "^1.13.6", - "@sendgrid/mail": "^7.7.0", "@sentry/browser": "^7.61.0", "@sentry/integrations": "^7.61.0", - "@sentry/tracing": "^7.61.0", "@sentry/vite-plugin": "^2.6.2", "@supabase/supabase-js": "^2.31.0", "@sveltejs/adapter-auto": "^2.1.0", - "@sveltejs/adapter-netlify": "^2.0.8", "@tailwindcss/forms": "^0.5.4", "@tinymce/tinymce-svelte": "^1.0.1", - "@types/paystack": "^2.0.1", "@types/pluralize": "0.0.30", "ai": "^2.1.31", "axios": "^1.5.1", @@ -40,7 +36,6 @@ "hotkeys-js": "^3.11.2", "js-yaml": "^4.1.0", "lodash": "^4.17.21", - "netlify": "^13.1.10", "nodemailer": "^6.9.5", "openai-edge": "^1.2.2", "pluralize": "^8.0.0", @@ -69,7 +64,6 @@ "postcss-load-config": "^4.0.1", "sass": "^1.64.2", "svelte": "^4.1.2", - "svelte-awesome": "^3.2.1", "svelte-calendar": "^3.1.6", "svelte-dnd-action": "^0.9.24", "svelte-loading-spinners": "^0.3.4", diff --git a/src/lib/components/CourseContainer/index.svelte b/src/lib/components/CourseContainer/index.svelte index 559418d5..6f4807f4 100644 --- a/src/lib/components/CourseContainer/index.svelte +++ b/src/lib/components/CourseContainer/index.svelte @@ -20,14 +20,17 @@ async function onCourseIdChange(courseId = '') { console.log('courseid changed', courseId); - if (!courseId || prevCourseId === courseId || !browser) return; + if (!courseId || prevCourseId === courseId || !browser || $course.id === courseId) return; + console.log('making request', courseId); isFetching = true; course.set(defaultCourse); const { data: _data } = await fetchCourse(courseId); - setCourse(_data); + if (_data) { + setCourse(_data); + } isFetching = false; prevCourseId = courseId; diff --git a/src/lib/components/CourseLandingPage/index.svelte b/src/lib/components/CourseLandingPage/index.svelte index 0df31447..e3889821 100644 --- a/src/lib/components/CourseLandingPage/index.svelte +++ b/src/lib/components/CourseLandingPage/index.svelte @@ -45,8 +45,6 @@ // initialize the expandDescription array with 'false' values for each review. let expandDescription = Array(reviews.length).fill(false); - // const paystackApi = paystack(''); - let activeNav = NAV_ITEMS[0].key; let instructor = {}; let video: string | undefined; diff --git a/src/lib/utils/services/sendgrid.ts b/src/lib/utils/services/sendgrid.ts deleted file mode 100644 index c51afdbe..00000000 --- a/src/lib/utils/services/sendgrid.ts +++ /dev/null @@ -1,18 +0,0 @@ -import SendGridService from '@sendgrid/mail'; -import type { MailService } from '@sendgrid/mail'; -import { SENDGRID_API_KEY } from '$env/static/private'; - -export const SENDGRID_FROM = 'Rotimi Best '; -export const SENDGRID_FROM_NOREPLY = 'ClassroomIO '; - -export let sendgrid: MailService; - -export const getSendgrid = (): MailService => { - if (sendgrid) return sendgrid; - - SendGridService.setApiKey(SENDGRID_API_KEY); - - sendgrid = SendGridService; - - return sendgrid; -}; diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index cf6dba1d..c8f4fe77 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -6,7 +6,6 @@ import { page, navigating } from '$app/stores'; import isEmpty from 'lodash/isEmpty'; import * as Sentry from '@sentry/browser'; - import { Integrations } from '@sentry/tracing'; import { CaptureConsole } from '@sentry/integrations'; import posthog from 'posthog-js'; import { Theme } from 'carbon-components-svelte'; @@ -57,13 +56,12 @@ Sentry.init({ dsn: 'https://c966f7e8cb1d4306be20b26bb4f0cc96@o476906.ingest.sentry.io/5999999', integrations: [ - new Integrations.BrowserTracing(), new CaptureConsole({ levels: ['error'] }), new Sentry.Replay() ], - environment: !dev ? 'production' : 'development', + environment: 'production', // This sets the sample rate to be 10%. You may want this to be 100% while // in development and sample at a lower rate in production replaysSessionSampleRate: 0.5, diff --git a/svelte.config.js b/svelte.config.js index 294f2dfa..614b5395 100644 --- a/svelte.config.js +++ b/svelte.config.js @@ -1,5 +1,4 @@ import autoAdapter from '@sveltejs/adapter-auto'; -import netlifyAdapter from '@sveltejs/adapter-netlify'; import { vitePreprocess } from '@sveltejs/kit/vite'; /** @type {import('@sveltejs/kit').Config} */ @@ -9,13 +8,7 @@ const config = { preprocess: [vitePreprocess({})], kit: { - adapter: - process.env.ADAPTER === 'NETLIFY' - ? netlifyAdapter({ - edge: false, - split: true - }) - : autoAdapter() + adapter: autoAdapter() } };