Skip to content

Commit

Permalink
fix(client): improved the browser tab's title generation to support a…
Browse files Browse the repository at this point in the history
…uthentication
  • Loading branch information
Will Moss committed Jul 18, 2024
1 parent 0221338 commit 8f37281
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Dependencies
import { useEffect, useState, useRef, useCallback } from "react";
import { useEffect, useState, useRef, useCallback, useMemo } from "react";

// Components
import VideoCard from "./components/VideoCard";
Expand Down Expand Up @@ -76,10 +76,12 @@ const App = () => {
const _isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);

const _toAuthenticatedUrl = (url) => `${url}?hash=${secureHash}`;
const _veryFirsPageTitle = document.title;
const _updatePageTitle = (video) => {
if (!_veryFirsPageTitle.includes("[VIDEO_TITLE]")) return;
document.title = _veryFirsPageTitle.replace("[VIDEO_TITLE]", video.title);
const _veryFirsPageTitle = useMemo(() => document.title, []);
const _updatePageTitle = (video = null) => {
if (video) {
if (!_veryFirsPageTitle.includes("[VIDEO_TITLE]")) document.title = _veryFirsPageTitle;
else document.title = _veryFirsPageTitle.replace("[VIDEO_TITLE]", video.title);
} else if (window.USE_SECRET) document.title = "Erin - Authentication";
};

// Method - Test connectivity with the remote server
Expand Down Expand Up @@ -176,6 +178,8 @@ const App = () => {

// Hook - On mount - Retrieve the locally-stored secret
useEffect(() => {
_updatePageTitle();

if (!window.USE_SECRET) {
setAutoconnect(true);
return;
Expand Down

0 comments on commit 8f37281

Please sign in to comment.