From bcf6b1e1d03ea3989988f8a1ae32231e87b42dd5 Mon Sep 17 00:00:00 2001 From: nflnkr Date: Sat, 6 Apr 2024 17:01:04 +0300 Subject: [PATCH 1/3] add prop to disable favicon and title change --- lib/components/QuizAnswerer.tsx | 5 +++-- .../ViewPublicationPage.tsx | 21 +++++++++---------- lib/contexts/QuizDataContext.ts | 6 +++++- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/lib/components/QuizAnswerer.tsx b/lib/components/QuizAnswerer.tsx index ad6a319..4a365af 100644 --- a/lib/components/QuizAnswerer.tsx +++ b/lib/components/QuizAnswerer.tsx @@ -26,9 +26,10 @@ type Props = { quizSettings?: QuizSettings; quizId: string; preview?: boolean; + changeFaviconAndTitle?: boolean; }; -export default function QuizAnswerer({ quizSettings, quizId, preview = false }: Props) { +export default function QuizAnswerer({ quizSettings, quizId, preview = false, changeFaviconAndTitle = true }: Props) { const [quizViewStore] = useState(createQuizViewStore); const [rootContainerWidth, setRootContainerWidth] = useState(() => window.innerWidth); const rootContainerRef = useRef(null); @@ -65,7 +66,7 @@ export default function QuizAnswerer({ quizSettings, quizId, preview = false }: return ( - + state.answers); let currentQuizStep = useQuizViewStore((state) => state.currentQuizStep); const { @@ -30,17 +30,16 @@ export default function ViewPublicationPage() { const isAnswer = answers.some(ans => ans.questionId === currentQuestion.id); - useEffect( - function setFaviconAndTitle() { - const link = document.querySelector('link[rel="icon"]'); - if (link && settings.cfg.startpage.favIcon) { - link.setAttribute("href", settings.cfg.startpage.favIcon); - } + useEffect(function setFaviconAndTitle() { + if (!changeFaviconAndTitle) return; - document.title = settings.name; - }, - [settings] - ); + const link = document.querySelector('link[rel="icon"]'); + if (link && settings.cfg.startpage.favIcon) { + link.setAttribute("href", settings.cfg.startpage.favIcon); + } + + document.title = settings.name; + }, [changeFaviconAndTitle, settings.cfg.startpage.favIcon, settings.name]); if (recentlyCompleted) throw new Error("Quiz already completed"); if (currentQuizStep === "startpage" && settings.cfg.noStartPage) diff --git a/lib/contexts/QuizDataContext.ts b/lib/contexts/QuizDataContext.ts index c87f447..24b6d54 100644 --- a/lib/contexts/QuizDataContext.ts +++ b/lib/contexts/QuizDataContext.ts @@ -1,7 +1,11 @@ import { QuizSettings } from "@model/settingsData"; import { createContext, useContext } from "react"; -type QuizData = QuizSettings & { quizId: string; preview: boolean; }; +type QuizData = QuizSettings & { + quizId: string; + preview: boolean; + changeFaviconAndTitle: boolean; +}; export const QuizDataContext = createContext(null); From 3dab3b9550a1ded41004a6d0075956329ee389d3 Mon Sep 17 00:00:00 2001 From: nflnkr Date: Sat, 6 Apr 2024 17:02:16 +0300 Subject: [PATCH 2/3] fix logo positioning --- .../ViewPublicationPage/Question.tsx | 32 +++++++++++++++---- package.json | 2 +- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/lib/components/ViewPublicationPage/Question.tsx b/lib/components/ViewPublicationPage/Question.tsx index 2f05850..b6c99b4 100644 --- a/lib/components/ViewPublicationPage/Question.tsx +++ b/lib/components/ViewPublicationPage/Question.tsx @@ -54,6 +54,8 @@ export const Question = ({ {show_badge && ( - + {quizThemes[settings.cfg.theme].isLight ? ( ) : ( )} diff --git a/package.json b/package.json index 3c8a700..baa1cef 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@frontend/squzanswerer", - "version": "1.0.18", + "version": "1.0.19", "type": "module", "main": "./dist-package/index.js", "module": "./dist-package/index.js", From c718bd1624fb5347385f291a8ae4ac1d3d4051ba Mon Sep 17 00:00:00 2001 From: Nastya Date: Sun, 7 Apr 2024 18:05:11 +0300 Subject: [PATCH 3/3] send uesragent --- lib/api/quizRelase.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/api/quizRelase.ts b/lib/api/quizRelase.ts index eeede44..e653904 100644 --- a/lib/api/quizRelase.ts +++ b/lib/api/quizRelase.ts @@ -43,10 +43,10 @@ export const publicationMakeRequest = ({ url, body }: any) => { headers: { "X-Sessionkey": SESSIONS, "Content-Type": "multipart/form-data", - // "DeviceType" : DeviceType, - // "Device" : Device, - // "OS": OSDevice, - // "Browser" : browserUser + "DeviceType" : DeviceType, + "Device" : Device, + "OS": OSDevice, + "Browser" : browserUser }, method: "POST", }); @@ -65,10 +65,10 @@ export async function getData(quizId: string): Promise<{ headers: { "X-Sessionkey": SESSIONS, "Content-Type": "application/json", - // "DeviceType" : DeviceType, - // "Device" : Device, - // "OS": OSDevice, - // "Browser" : userAgent + "DeviceType" : DeviceType, + "Device" : Device, + "OS": OSDevice, + "Browser" : userAgent }, data: { quiz_id: quizId,