mirror of
https://github.com/owncast/owncast.git
synced 2025-11-02 03:54:54 +08:00
Use built-in Next layout support + lazy load
Instead of doing manual layout switching use the Nextjs nested layout support. Also add some additional lazy loading of components. This is to work on performance score re: #2167.
This commit is contained in:
@ -0,0 +1,12 @@
|
||||
# EditorConfig is awesome: https://EditorConfig.org
|
||||
|
||||
# top-most EditorConfig file
|
||||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = false
|
||||
insert_final_newline = false
|
||||
@ -0,0 +1,27 @@
|
||||
/* eslint-disable react/no-danger */
|
||||
import { FC, useEffect } from 'react';
|
||||
|
||||
export const PushNotificationServiceWorker: FC = () => {
|
||||
const add = () => {
|
||||
navigator.serviceWorker.register('/serviceWorker.js').then(
|
||||
registration => {
|
||||
console.debug('Service Worker registration successful with scope: ', registration.scope);
|
||||
},
|
||||
err => {
|
||||
console.error('Service Worker registration failed: ', err);
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if ('serviceWorker' in navigator) {
|
||||
window.addEventListener('load', add);
|
||||
}
|
||||
|
||||
return () => {
|
||||
window.removeEventListener('load', add);
|
||||
};
|
||||
}, []);
|
||||
|
||||
return null;
|
||||
};
|
||||
Reference in New Issue
Block a user