setWindowTitleAndIcon.tsx
TLDR
This file is a React component that sets the window title and favicon based on the current state of the board and active view.
Methods
There are no methods in this file.
Classes
There are no classes in this file.
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {useEffect} from 'react'
import {Utils} from '../../utils'
import {getCurrentBoard} from '../../store/boards'
import {getCurrentView} from '../../store/views'
import {useAppSelector} from '../../store/hooks'
const SetWindowTitleAndIcon = (): null => {
const board = useAppSelector(getCurrentBoard)
const activeView = useAppSelector(getCurrentView)
useEffect(() => {
Utils.setFavicon(board?.icon)
}, [board?.icon])
useEffect(() => {
if (board) {
let title = `${board.title}`
if (activeView?.title) {
title += ` | ${activeView.title}`
}
document.title = title
} else if (Utils.isFocalboardPlugin()) {
document.title = 'Boards - Mattermost'
} else {
document.title = 'Focalboard'
}
}, [board?.title, activeView?.title])
return null
}
export default SetWindowTitleAndIcon