2021-06-04 07:57:48 +00:00
|
|
|
import React, { createContext, useEffect, useState } from 'react';
|
2021-05-30 16:56:48 +00:00
|
|
|
import styled, { createGlobalStyle } from 'styled-components';
|
2020-09-09 21:09:51 +00:00
|
|
|
import Navbar from 'components/Navbar';
|
2020-09-12 21:53:41 +00:00
|
|
|
import constants from 'utils/strings/constants';
|
2021-05-30 16:56:48 +00:00
|
|
|
import { useRouter } from 'next/router';
|
2020-09-13 17:01:36 +00:00
|
|
|
import Container from 'components/Container';
|
2020-09-14 09:32:01 +00:00
|
|
|
import Head from 'next/head';
|
2020-09-20 15:18:35 +00:00
|
|
|
import 'bootstrap/dist/css/bootstrap.min.css';
|
2021-02-26 08:13:46 +00:00
|
|
|
import 'photoswipe/dist/photoswipe.css';
|
2021-04-18 13:01:40 +00:00
|
|
|
import EnteSpinner from 'components/EnteSpinner';
|
2021-06-07 10:45:46 +00:00
|
|
|
import { logError } from '../utils/sentry';
|
2021-05-30 16:56:48 +00:00
|
|
|
import { Workbox } from 'workbox-window';
|
2021-06-07 18:58:52 +00:00
|
|
|
import { getEndpoint } from 'utils/common/apiUtil';
|
|
|
|
import { getData, LS_KEYS } from 'utils/storage/localStorage';
|
2021-06-12 18:33:25 +00:00
|
|
|
import HTTPService from 'services/HTTPService';
|
2020-09-09 21:09:51 +00:00
|
|
|
|
|
|
|
const GlobalStyles = createGlobalStyle`
|
2021-04-23 15:35:48 +00:00
|
|
|
/* ubuntu-regular - latin */
|
|
|
|
@font-face {
|
|
|
|
font-family: 'Ubuntu';
|
|
|
|
font-style: normal;
|
|
|
|
font-weight: 400;
|
|
|
|
src: local(''),
|
|
|
|
url('/fonts/ubuntu-v15-latin-regular.woff2') format('woff2'), /* Chrome 26+, Opera 23+, Firefox 39+ */
|
|
|
|
url('/fonts/ubuntu-v15-latin-regular.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ubuntu-700 - latin */
|
|
|
|
@font-face {
|
|
|
|
font-family: 'Ubuntu';
|
|
|
|
font-style: normal;
|
|
|
|
font-weight: 700;
|
|
|
|
src: local(''),
|
|
|
|
url('/fonts/ubuntu-v15-latin-700.woff2') format('woff2'), /* Chrome 26+, Opera 23+, Firefox 39+ */
|
|
|
|
url('/fonts/ubuntu-v15-latin-700.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */
|
|
|
|
}
|
2020-09-09 21:09:51 +00:00
|
|
|
html, body {
|
|
|
|
padding: 0;
|
|
|
|
margin: 0;
|
|
|
|
font-family: Arial, Helvetica, sans-serif;
|
|
|
|
height: 100%;
|
|
|
|
flex: 1;
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
2021-02-15 12:42:03 +00:00
|
|
|
background-color: #191919;
|
2021-03-12 11:43:02 +00:00
|
|
|
color: #aaa;
|
2021-04-28 06:58:32 +00:00
|
|
|
font-family:Ubuntu, Arial, sans-serif !important;
|
2020-09-09 21:09:51 +00:00
|
|
|
}
|
2021-06-24 08:32:29 +00:00
|
|
|
:is(h1, h2, h3, h4, h5, h6) {
|
|
|
|
color: #d7d7d7;
|
|
|
|
}
|
2020-09-09 21:09:51 +00:00
|
|
|
|
|
|
|
#__next {
|
|
|
|
flex: 1;
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
}
|
|
|
|
|
|
|
|
.material-icons {
|
|
|
|
vertical-align: middle;
|
|
|
|
margin: 8px;
|
|
|
|
}
|
2020-11-26 15:57:20 +00:00
|
|
|
|
|
|
|
.pswp__item video {
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
}
|
|
|
|
|
|
|
|
.video-loading {
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
position: relative;
|
|
|
|
}
|
|
|
|
|
|
|
|
.video-loading > img {
|
|
|
|
object-fit: contain;
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
}
|
|
|
|
|
|
|
|
.video-loading > div {
|
|
|
|
position: relative;
|
|
|
|
top: -50vh;
|
|
|
|
left: 50vw;
|
|
|
|
}
|
2020-09-09 21:09:51 +00:00
|
|
|
|
|
|
|
:root {
|
|
|
|
--primary: #e26f99,
|
|
|
|
};
|
2020-09-13 17:01:36 +00:00
|
|
|
|
|
|
|
svg {
|
|
|
|
fill: currentColor;
|
|
|
|
}
|
2020-10-03 14:21:56 +00:00
|
|
|
|
|
|
|
.pswp__img {
|
|
|
|
object-fit: contain;
|
|
|
|
}
|
2021-05-08 05:20:48 +00:00
|
|
|
|
2021-03-13 07:25:18 +00:00
|
|
|
.modal {
|
|
|
|
z-index: 2000;
|
|
|
|
}
|
2021-04-21 06:56:57 +00:00
|
|
|
.modal-dialog-centered {
|
2021-05-08 05:28:16 +00:00
|
|
|
min-height: -webkit-calc(80% - 3.5rem);
|
|
|
|
min-height: -moz-calc(80% - 3.5rem);
|
|
|
|
min-height: calc(80% - 3.5rem);
|
2021-04-21 06:56:57 +00:00
|
|
|
}
|
2021-03-13 07:25:18 +00:00
|
|
|
.modal .modal-header, .modal .modal-footer {
|
2021-01-24 20:22:12 +00:00
|
|
|
border-color: #444 !important;
|
|
|
|
}
|
|
|
|
.modal .modal-header .close {
|
|
|
|
color: #aaa;
|
|
|
|
text-shadow: none;
|
|
|
|
}
|
2021-04-19 09:52:45 +00:00
|
|
|
.modal-backdrop {
|
|
|
|
z-index:2000;
|
2021-06-11 07:34:35 +00:00
|
|
|
opacity:0.8 !important;
|
2021-04-19 09:52:45 +00:00
|
|
|
}
|
2021-04-26 07:44:56 +00:00
|
|
|
.modal .card , .table {
|
2021-02-15 13:19:59 +00:00
|
|
|
background-color: #202020;
|
2021-01-24 20:22:12 +00:00
|
|
|
border: none;
|
|
|
|
}
|
|
|
|
.modal .card > div {
|
|
|
|
border-radius: 30px;
|
|
|
|
overflow: hidden;
|
|
|
|
margin: 0 0 5px 0;
|
2021-01-14 14:07:26 +00:00
|
|
|
}
|
2021-02-15 10:46:16 +00:00
|
|
|
.modal-content {
|
2021-04-19 08:29:12 +00:00
|
|
|
border-radius:15px;
|
2021-02-15 13:19:59 +00:00
|
|
|
background-color:#202020 !important;
|
2021-01-24 20:22:12 +00:00
|
|
|
color:#aaa;
|
2021-01-14 12:34:55 +00:00
|
|
|
}
|
2021-05-08 06:14:30 +00:00
|
|
|
.modal-dialog{
|
|
|
|
margin:5% auto;
|
2021-05-09 06:53:56 +00:00
|
|
|
width:90%;
|
|
|
|
}
|
|
|
|
.modal-xl{
|
|
|
|
max-width:960px!important;
|
2021-05-08 06:14:30 +00:00
|
|
|
}
|
2021-06-05 15:40:44 +00:00
|
|
|
.pswp-custom {
|
|
|
|
opacity: 0.75;
|
|
|
|
transition: opacity .2s;
|
|
|
|
display: inline-block;
|
2021-02-15 08:14:33 +00:00
|
|
|
float: right;
|
|
|
|
cursor: pointer;
|
2021-06-05 15:03:54 +00:00
|
|
|
border: none;
|
2021-06-05 15:40:44 +00:00
|
|
|
height: 44px;
|
|
|
|
width: 44px;
|
|
|
|
}
|
|
|
|
.pswp-custom:hover {
|
|
|
|
opacity: 1;
|
|
|
|
}
|
|
|
|
.download-btn{
|
|
|
|
background: url('/download_icon.png') no-repeat;
|
|
|
|
background-size: 20px 20px;
|
|
|
|
background-position: center;
|
2021-06-05 15:03:54 +00:00
|
|
|
}
|
|
|
|
.info-btn{
|
|
|
|
background: url('/info_icon.png') no-repeat;
|
2021-06-05 15:40:44 +00:00
|
|
|
background-size: 20px 20px;
|
2021-06-05 15:03:54 +00:00
|
|
|
background-position: center;
|
2021-02-17 09:09:43 +00:00
|
|
|
}
|
2021-06-06 21:21:55 +00:00
|
|
|
.share-btn{
|
|
|
|
background: url('/share_icon.png') no-repeat;
|
|
|
|
background-size: 20px 20px;
|
|
|
|
background-position: center;
|
|
|
|
}
|
2021-06-17 10:45:52 +00:00
|
|
|
.btn.focus , .btn:focus{
|
|
|
|
box-shadow: none;
|
|
|
|
}
|
2021-04-11 05:08:06 +00:00
|
|
|
.btn-success {
|
2021-02-15 10:46:16 +00:00
|
|
|
background: #2dc262;
|
2021-02-15 11:34:11 +00:00
|
|
|
border-color: #29a354;
|
2021-02-15 10:46:16 +00:00
|
|
|
}
|
2021-04-11 05:08:06 +00:00
|
|
|
.btn-success:hover ,.btn-success:focus .btn-success:active{
|
2021-02-15 10:46:16 +00:00
|
|
|
background-color: #29a354;
|
2021-02-15 11:34:11 +00:00
|
|
|
border-color: #2dc262;
|
2021-02-15 10:46:16 +00:00
|
|
|
}
|
2021-04-08 06:18:28 +00:00
|
|
|
.btn-success:disabled {
|
2021-02-15 10:46:16 +00:00
|
|
|
background-color: #69b383;
|
|
|
|
}
|
2021-04-08 06:18:28 +00:00
|
|
|
.btn-outline-success {
|
2021-03-22 13:02:16 +00:00
|
|
|
color: #2dc262;
|
|
|
|
border-color: #2dc262;
|
2021-04-05 13:53:12 +00:00
|
|
|
border-width: 2px;
|
2021-03-22 13:02:16 +00:00
|
|
|
}
|
2021-04-08 06:18:28 +00:00
|
|
|
.btn-outline-success:hover {
|
2021-03-22 13:02:16 +00:00
|
|
|
background: #2dc262;
|
|
|
|
}
|
2021-04-11 05:08:06 +00:00
|
|
|
.btn-outline-danger, .btn-outline-secondary, .btn-outline-primary{
|
2021-04-05 13:59:48 +00:00
|
|
|
border-width: 2px;
|
|
|
|
}
|
2021-02-15 12:42:03 +00:00
|
|
|
.card {
|
|
|
|
background-color: #242424;
|
2021-04-19 08:29:12 +00:00
|
|
|
color: #d1d1d1;
|
2021-02-15 12:42:03 +00:00
|
|
|
border-radius: 12px;
|
2021-02-15 08:14:33 +00:00
|
|
|
}
|
2021-03-09 07:41:52 +00:00
|
|
|
.jumbotron{
|
2021-03-09 10:36:23 +00:00
|
|
|
background-color: #191919;
|
2021-04-19 08:29:12 +00:00
|
|
|
color: #d1d1d1;
|
2021-03-09 10:36:23 +00:00
|
|
|
text-align: center;
|
|
|
|
margin-top: 50px;
|
|
|
|
}
|
|
|
|
.alert-success {
|
2021-05-22 18:40:34 +00:00
|
|
|
background-color: rgb(235, 255, 243);
|
2021-04-05 14:32:15 +00:00
|
|
|
color: #000000;
|
2021-03-09 10:36:23 +00:00
|
|
|
}
|
|
|
|
.alert-primary {
|
|
|
|
background-color: #c4ffd6;
|
2021-03-09 07:41:52 +00:00
|
|
|
}
|
2021-03-11 16:04:34 +00:00
|
|
|
.bm-burger-button {
|
|
|
|
position: fixed;
|
2021-04-28 09:44:00 +00:00
|
|
|
width: 24px;
|
|
|
|
height: 16px;
|
2021-05-26 12:49:18 +00:00
|
|
|
top:27px;
|
2021-03-22 10:20:15 +00:00
|
|
|
left: 32px;
|
2021-05-26 06:21:50 +00:00
|
|
|
z-index:100 !important;
|
2021-03-13 05:18:16 +00:00
|
|
|
}
|
2021-03-11 16:04:34 +00:00
|
|
|
.bm-burger-bars {
|
2021-03-13 05:18:16 +00:00
|
|
|
background: #bdbdbd;
|
|
|
|
}
|
2021-03-22 10:20:15 +00:00
|
|
|
.bm-menu-wrap {
|
|
|
|
top:0px;
|
|
|
|
}
|
2021-03-13 05:18:16 +00:00
|
|
|
.bm-menu {
|
2021-03-13 07:00:40 +00:00
|
|
|
background: #131313;
|
2021-03-11 16:04:34 +00:00
|
|
|
font-size: 1.15em;
|
2021-05-23 05:49:53 +00:00
|
|
|
color:#d1d1d1;
|
|
|
|
display: flex;
|
2021-03-13 05:18:16 +00:00
|
|
|
}
|
|
|
|
.bm-cross {
|
2021-04-19 08:29:12 +00:00
|
|
|
background: #d1d1d1;
|
2021-03-13 05:18:16 +00:00
|
|
|
}
|
2021-05-23 05:49:53 +00:00
|
|
|
.bm-cross-button {
|
2021-05-23 12:04:29 +00:00
|
|
|
top: 20px !important;
|
2021-05-23 05:49:53 +00:00
|
|
|
}
|
|
|
|
.bm-item-list {
|
2021-05-23 12:04:29 +00:00
|
|
|
display: flex !important;
|
2021-05-23 05:49:53 +00:00
|
|
|
flex-direction: column;
|
|
|
|
max-height: 100%;
|
|
|
|
flex: 1;
|
|
|
|
}
|
|
|
|
.bm-item {
|
|
|
|
padding: 20px;
|
|
|
|
}
|
|
|
|
.bm-overlay {
|
|
|
|
top: 0;
|
|
|
|
background: rgba(0, 0, 0, 0.8) !important;
|
|
|
|
}
|
2021-03-22 12:22:15 +00:00
|
|
|
.bg-upload-progress-bar {
|
|
|
|
background-color: #2dc262;
|
|
|
|
}
|
2021-04-18 10:33:22 +00:00
|
|
|
.custom-switch.custom-switch-md .custom-control-label {
|
|
|
|
padding-left: 2rem;
|
|
|
|
padding-bottom: 1.5rem;
|
|
|
|
}
|
|
|
|
|
|
|
|
.custom-switch.custom-switch-md .custom-control-label::before {
|
|
|
|
height: 1.5rem;
|
2021-04-19 08:29:12 +00:00
|
|
|
background-color: #303030;
|
|
|
|
border: none;
|
2021-04-18 10:33:22 +00:00
|
|
|
width: calc(2.5rem + 0.75rem);
|
|
|
|
border-radius: 3rem;
|
|
|
|
}
|
2021-04-19 08:29:12 +00:00
|
|
|
.custom-switch.custom-switch-md:active .custom-control-label::before {
|
|
|
|
background-color: #303030;
|
|
|
|
}
|
2021-04-18 10:33:22 +00:00
|
|
|
|
|
|
|
.custom-switch.custom-switch-md .custom-control-label::after {
|
2021-04-19 08:29:12 +00:00
|
|
|
top:2px;
|
|
|
|
background:#c4c4c4;
|
|
|
|
width: calc(2.0rem - 4px);
|
|
|
|
height: calc(2.0rem - 4px);
|
|
|
|
border-radius: calc(2rem - (2.0rem / 2));
|
2021-05-23 12:04:29 +00:00
|
|
|
left: -38px;
|
2021-04-18 10:33:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.custom-switch.custom-switch-md .custom-control-input:checked ~ .custom-control-label::after {
|
|
|
|
transform: translateX(calc(2.0rem - 0.25rem));
|
2021-04-19 08:29:12 +00:00
|
|
|
background:#c4c4c4;
|
2021-04-18 10:33:22 +00:00
|
|
|
}
|
2021-05-23 12:04:29 +00:00
|
|
|
|
|
|
|
.custom-control-input:checked ~ .custom-control-label::before {
|
|
|
|
background-color: #29a354;
|
|
|
|
}
|
|
|
|
|
2021-04-18 10:41:56 +00:00
|
|
|
.bold-text{
|
|
|
|
color: #ECECEC;
|
|
|
|
line-height: 24px;
|
|
|
|
font-size: 24px;
|
|
|
|
}
|
2021-04-24 10:54:16 +00:00
|
|
|
.dropdown-item:active{
|
|
|
|
color: #16181b;
|
|
|
|
text-decoration: none;
|
|
|
|
background-color: #e9ecef;
|
|
|
|
}
|
2021-04-25 15:01:44 +00:00
|
|
|
.submitButton:hover > .spinner-border{
|
|
|
|
color:white;
|
|
|
|
}
|
2021-04-26 07:44:56 +00:00
|
|
|
hr{
|
|
|
|
border-top: 1rem solid #444 !important;
|
|
|
|
}
|
2021-04-28 06:58:32 +00:00
|
|
|
.list-group-item:hover{
|
|
|
|
background-color:#343434 !important;
|
|
|
|
}
|
|
|
|
.list-group-item:active , list-group-item:focus{
|
|
|
|
background-color:#000 !important;
|
|
|
|
}
|
2021-04-28 09:56:45 +00:00
|
|
|
.arrow::after{
|
|
|
|
border-bottom-color:#282828 !important;
|
|
|
|
}
|
2021-06-04 20:43:13 +00:00
|
|
|
.carousel-inner {
|
|
|
|
padding-bottom: 50px !important;
|
|
|
|
}
|
|
|
|
.carousel-indicators li {
|
|
|
|
width: 10px;
|
|
|
|
height: 10px;
|
|
|
|
border-radius: 50%;
|
2021-06-04 20:58:08 +00:00
|
|
|
margin-right: 12px;
|
2021-06-04 20:43:13 +00:00
|
|
|
}
|
|
|
|
.carousel-indicators .active {
|
|
|
|
background-color: #2dc262;
|
|
|
|
}
|
2021-06-21 15:22:21 +00:00
|
|
|
div.otp-input input {
|
|
|
|
width: 2em !important;
|
|
|
|
height: 3em;
|
|
|
|
margin: 0 10px;
|
|
|
|
}
|
2020-09-09 21:09:51 +00:00
|
|
|
`;
|
|
|
|
|
2021-05-24 15:58:45 +00:00
|
|
|
export const LogoImage = styled.img`
|
2021-02-09 09:33:54 +00:00
|
|
|
max-height: 28px;
|
|
|
|
margin-right: 5px;
|
2020-09-09 21:09:51 +00:00
|
|
|
`;
|
|
|
|
|
2020-09-13 06:30:07 +00:00
|
|
|
const FlexContainer = styled.div`
|
2021-02-09 09:33:54 +00:00
|
|
|
flex: 1;
|
2021-02-15 09:21:52 +00:00
|
|
|
text-align: center;
|
2020-09-13 06:30:07 +00:00
|
|
|
`;
|
2020-09-12 21:53:41 +00:00
|
|
|
|
2021-06-06 20:26:31 +00:00
|
|
|
export const MessageContainer = styled.div`
|
2021-05-23 14:25:48 +00:00
|
|
|
background-color: #111;
|
2021-05-29 22:11:52 +00:00
|
|
|
padding: 0;
|
2021-05-23 14:25:48 +00:00
|
|
|
font-size: 14px;
|
|
|
|
text-align: center;
|
2021-05-29 22:11:52 +00:00
|
|
|
line-height: 32px;
|
2021-05-23 14:25:48 +00:00
|
|
|
`;
|
|
|
|
|
2021-03-17 12:07:20 +00:00
|
|
|
export interface BannerMessage {
|
|
|
|
message: string;
|
|
|
|
variant: string;
|
|
|
|
}
|
|
|
|
|
2021-06-04 07:57:48 +00:00
|
|
|
|
|
|
|
type AppContextType = {
|
|
|
|
showNavBar: (show: boolean) => void;
|
2021-06-08 09:53:11 +00:00
|
|
|
sharedFiles: File[];
|
|
|
|
resetSharedFiles: () => void;
|
2021-06-04 07:57:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export const AppContext = createContext<AppContextType>(null);
|
|
|
|
|
2021-06-07 18:58:52 +00:00
|
|
|
const redirectMap = {
|
2021-06-12 18:33:25 +00:00
|
|
|
roadmap: (token: string) => `${getEndpoint()}/users/roadmap?token=${encodeURIComponent(token)}`,
|
2021-06-07 18:58:52 +00:00
|
|
|
};
|
|
|
|
|
2021-05-30 16:56:48 +00:00
|
|
|
export default function App({ Component, err }) {
|
2021-01-14 12:34:55 +00:00
|
|
|
const router = useRouter();
|
|
|
|
const [loading, setLoading] = useState(false);
|
2021-05-24 15:58:45 +00:00
|
|
|
const [offline, setOffline] = useState(
|
2021-05-29 06:27:52 +00:00
|
|
|
typeof window !== 'undefined' && !window.navigator.onLine,
|
2021-05-24 15:58:45 +00:00
|
|
|
);
|
2021-06-04 07:57:48 +00:00
|
|
|
const [showNavbar, setShowNavBar] = useState(false);
|
2021-06-08 09:53:11 +00:00
|
|
|
const [sharedFiles, setSharedFiles] = useState<File[]>(null);
|
2021-06-07 18:58:52 +00:00
|
|
|
const [redirectName, setRedirectName] = useState<string>(null);
|
2021-06-04 07:57:48 +00:00
|
|
|
|
2021-05-28 05:44:20 +00:00
|
|
|
useEffect(() => {
|
2021-05-29 22:02:06 +00:00
|
|
|
if (
|
|
|
|
!('serviceWorker' in navigator) ||
|
|
|
|
process.env.NODE_ENV !== 'production'
|
|
|
|
) {
|
|
|
|
console.warn('Progressive Web App support is disabled');
|
|
|
|
return;
|
2021-05-28 05:44:20 +00:00
|
|
|
}
|
2021-05-30 16:56:48 +00:00
|
|
|
const wb = new Workbox('sw.js', { scope: '/' });
|
2021-05-29 22:02:06 +00:00
|
|
|
wb.register();
|
|
|
|
|
2021-06-06 20:26:31 +00:00
|
|
|
if ('serviceWorker' in navigator) {
|
|
|
|
navigator.serviceWorker.onmessage = (event) => {
|
|
|
|
if (event.data.action === 'upload-files') {
|
|
|
|
const files = event.data.files;
|
2021-06-08 09:53:11 +00:00
|
|
|
setSharedFiles(files);
|
2021-06-06 20:26:31 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
2021-06-12 18:33:25 +00:00
|
|
|
|
|
|
|
HTTPService.getInterceptors().response.use(
|
|
|
|
(resp) => resp,
|
|
|
|
(error) => {
|
|
|
|
logError(error);
|
|
|
|
return Promise.reject(error);
|
|
|
|
},
|
|
|
|
);
|
2021-05-28 05:44:20 +00:00
|
|
|
}, []);
|
2021-01-14 12:34:55 +00:00
|
|
|
|
2021-05-23 14:25:48 +00:00
|
|
|
const setUserOnline = () => setOffline(false);
|
|
|
|
const setUserOffline = () => setOffline(true);
|
2021-06-08 09:53:11 +00:00
|
|
|
const resetSharedFiles = () => setSharedFiles(null);
|
2021-05-24 15:58:45 +00:00
|
|
|
|
2021-01-14 12:34:55 +00:00
|
|
|
useEffect(() => {
|
|
|
|
console.log(
|
|
|
|
`%c${constants.CONSOLE_WARNING_STOP}`,
|
2021-05-29 06:27:52 +00:00
|
|
|
'color: red; font-size: 52px;',
|
2021-01-14 12:34:55 +00:00
|
|
|
);
|
|
|
|
console.log(`%c${constants.CONSOLE_WARNING_DESC}`, 'font-size: 20px;');
|
|
|
|
|
2021-06-07 18:58:52 +00:00
|
|
|
const query = new URLSearchParams(window.location.search);
|
|
|
|
const redirect = query.get('redirect');
|
|
|
|
if (redirect && redirectMap[redirect]) {
|
|
|
|
const user = getData(LS_KEYS.USER);
|
|
|
|
if (user?.token) {
|
|
|
|
window.location.href = redirectMap[redirect](user.token);
|
|
|
|
} else {
|
|
|
|
setRedirectName(redirect);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-14 12:34:55 +00:00
|
|
|
router.events.on('routeChangeStart', (url: string) => {
|
|
|
|
if (window.location.pathname !== url.split('?')[0]) {
|
|
|
|
setLoading(true);
|
|
|
|
}
|
2021-06-07 18:58:52 +00:00
|
|
|
|
|
|
|
if (redirectName) {
|
|
|
|
const user = getData(LS_KEYS.USER);
|
|
|
|
if (user?.token) {
|
|
|
|
window.location.href = redirectMap[redirectName](user.token);
|
|
|
|
}
|
|
|
|
}
|
2021-01-14 12:34:55 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
router.events.on('routeChangeComplete', () => {
|
|
|
|
setLoading(false);
|
|
|
|
});
|
2021-05-23 14:25:48 +00:00
|
|
|
|
2021-05-24 15:58:45 +00:00
|
|
|
window.addEventListener('online', setUserOnline);
|
2021-05-23 14:25:48 +00:00
|
|
|
window.addEventListener('offline', setUserOffline);
|
|
|
|
|
|
|
|
return () => {
|
|
|
|
window.removeEventListener('online', setUserOnline);
|
|
|
|
window.removeEventListener('offline', setUserOffline);
|
2021-05-24 15:58:45 +00:00
|
|
|
};
|
2021-06-07 18:58:52 +00:00
|
|
|
}, [redirectName]);
|
2021-05-23 14:25:48 +00:00
|
|
|
|
2021-06-04 07:57:48 +00:00
|
|
|
const showNavBar = (show: boolean) => setShowNavBar(show);
|
|
|
|
|
2021-01-14 12:34:55 +00:00
|
|
|
return (
|
2021-03-18 20:16:18 +00:00
|
|
|
<>
|
2021-01-19 03:41:56 +00:00
|
|
|
<Head>
|
2021-02-27 11:01:25 +00:00
|
|
|
<title>{constants.TITLE}</title>
|
2021-04-15 08:50:18 +00:00
|
|
|
{/* Cloudflare Web Analytics */}
|
2021-06-08 12:19:20 +00:00
|
|
|
{process.env.NODE_ENV === 'production' &&
|
|
|
|
<script
|
|
|
|
defer
|
|
|
|
src="https://static.cloudflareinsights.com/beacon.min.js"
|
|
|
|
data-cf-beacon='{"token": "6a388287b59c439cb2070f78cc89dde1"}'
|
|
|
|
/>
|
|
|
|
}
|
2021-04-15 08:50:18 +00:00
|
|
|
{/* End Cloudflare Web Analytics */}
|
2021-01-19 03:41:56 +00:00
|
|
|
</Head>
|
|
|
|
<GlobalStyles />
|
2021-06-04 07:57:48 +00:00
|
|
|
{showNavbar && <Navbar>
|
2021-01-19 03:41:56 +00:00
|
|
|
<FlexContainer>
|
2021-05-24 15:58:45 +00:00
|
|
|
<LogoImage
|
2021-05-30 16:56:48 +00:00
|
|
|
style={{ height: '24px', padding: '3px' }}
|
2021-03-08 13:39:53 +00:00
|
|
|
alt="logo"
|
|
|
|
src="/icon.svg"
|
|
|
|
/>
|
2021-01-19 03:41:56 +00:00
|
|
|
</FlexContainer>
|
2021-06-04 07:57:48 +00:00
|
|
|
</Navbar>}
|
2021-06-06 20:26:31 +00:00
|
|
|
<MessageContainer>{offline && constants.OFFLINE_MSG}</MessageContainer>
|
2021-06-08 09:53:11 +00:00
|
|
|
{sharedFiles &&
|
2021-06-06 20:26:31 +00:00
|
|
|
(router.pathname === '/gallery' ?
|
2021-06-08 09:53:11 +00:00
|
|
|
<MessageContainer>{constants.FILES_TO_BE_UPLOADED(sharedFiles.length)}</MessageContainer> :
|
|
|
|
<MessageContainer>{constants.LOGIN_TO_UPLOAD_FILES(sharedFiles.length)}</MessageContainer>)}
|
2021-06-04 07:57:48 +00:00
|
|
|
<AppContext.Provider value={{
|
|
|
|
showNavBar,
|
2021-06-08 09:53:11 +00:00
|
|
|
sharedFiles,
|
|
|
|
resetSharedFiles,
|
2021-06-04 07:57:48 +00:00
|
|
|
}}>
|
|
|
|
{loading ? (
|
|
|
|
<Container>
|
|
|
|
<EnteSpinner>
|
|
|
|
<span className="sr-only">Loading...</span>
|
|
|
|
</EnteSpinner>
|
|
|
|
</Container>
|
|
|
|
) : (
|
|
|
|
<Component err={err} setLoading={setLoading} />
|
|
|
|
)}
|
|
|
|
</AppContext.Provider>
|
2021-03-18 20:16:18 +00:00
|
|
|
</>
|
2020-09-09 21:09:51 +00:00
|
|
|
);
|
2021-01-05 02:26:34 +00:00
|
|
|
}
|