From 8ab84442225ff544488caf598e83f33376d7251f Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Tue, 3 Aug 2021 11:14:36 +1000 Subject: [PATCH] remove expire warning. app asks to update on app start --- background.html | 1 - background_test.html | 1 - js/expire.js | 96 ------------------- test/index.html | 2 - ts/components/LeftPane.tsx | 30 +++--- ts/components/session/SessionInboxView.tsx | 13 +-- .../session/network/SessionExpiredWarning.tsx | 28 ------ ts/window.d.ts | 4 - 8 files changed, 12 insertions(+), 163 deletions(-) delete mode 100644 js/expire.js delete mode 100644 ts/components/session/network/SessionExpiredWarning.tsx diff --git a/background.html b/background.html index 3e21aa937..bcfa62864 100644 --- a/background.html +++ b/background.html @@ -54,7 +54,6 @@ - diff --git a/background_test.html b/background_test.html index 2e04c0cab..b70961c69 100644 --- a/background_test.html +++ b/background_test.html @@ -54,7 +54,6 @@ - diff --git a/js/expire.js b/js/expire.js deleted file mode 100644 index 0f4ecdb8b..000000000 --- a/js/expire.js +++ /dev/null @@ -1,96 +0,0 @@ -/* global semver, log */ -// eslint-disable-next-line func-names -(function() { - 'use strict'; - - // hold last result - let expiredVersion = null; - - let nextWaitSeconds = 5; - const checkForUpgrades = async () => { - try { - window.libsession.Utils.UserUtils.getOurPubKeyStrFromCache(); - } catch (e) { - // give it a minute - log.warn('Could not check to see if newer version is available cause our pubkey is not set'); - nextWaitSeconds = 60; - setTimeout(async () => { - await checkForUpgrades(); - }, nextWaitSeconds * 1000); // wait a minute - return; - } - let latestVersionWithV; - try { - latestVersionWithV = await window.Fsv2.getLatestDesktopReleaseFileToFsV2(); - if (!latestVersionWithV) { - throw new Error('Invalid latest version. Scheduling retry...'); - } - const latestVer = semver.clean(latestVersionWithV); - if (semver.valid(latestVer)) { - const ourVersion = window.getVersion(); - if (latestVer === ourVersion) { - log.info('You have the latest version', latestVer); - // change the following to true ot test/see expiration banner - expiredVersion = false; - } else { - // expire if latest is newer than current - expiredVersion = semver.gt(latestVer, ourVersion); - if (expiredVersion) { - log.info('There is a newer version available', latestVer); - } - } - } - } catch (e) { - window.log.warn('Failed to fetch latest version'); - log.warn('Could not check to see if newer version is available', latestVersionWithV); - } - // wait an hour before retrying - // do this even if we did not get an error before (to be sure to pick up a new release even if - // another request told us we were up to date) - - nextWaitSeconds = 3600; - setTimeout(async () => { - await checkForUpgrades(); - }, nextWaitSeconds * 1000); - // no message logged means serverRequest never returned... - }; - - // don't wait for this to finish - checkForUpgrades(); - - window.extension = window.extension || {}; - - // eslint-disable-next-line no-unused-vars - const resolveWhenReady = (res, rej) => { - if (expiredVersion !== null) { - return res(expiredVersion); - } - function waitForVersion() { - if (expiredVersion !== null) { - return res(expiredVersion); - } - log.info(`Delaying sending checks for ${nextWaitSeconds}s, no version yet`); - setTimeout(waitForVersion, nextWaitSeconds * 1000); - return true; - } - waitForVersion(); - return true; - }; - - // just get current status - window.extension.expiredStatus = () => expiredVersion; - // actually wait until we know for sure - window.extension.expiredPromise = () => new Promise(resolveWhenReady); - window.extension.expired = cb => { - if (expiredVersion === null) { - // just give it another second - log.info(`Delaying expire banner determination for ${nextWaitSeconds}s`); - setTimeout(() => { - window.extension.expired(cb); - }, nextWaitSeconds * 1000); - return; - } - // yes we know - cb(expiredVersion); - }; -})(); diff --git a/test/index.html b/test/index.html index 5818b0412..e0f5e683c 100644 --- a/test/index.html +++ b/test/index.html @@ -28,8 +28,6 @@ - - diff --git a/ts/components/LeftPane.tsx b/ts/components/LeftPane.tsx index a2d21d170..934cf0346 100644 --- a/ts/components/LeftPane.tsx +++ b/ts/components/LeftPane.tsx @@ -6,7 +6,6 @@ import { LeftPaneMessageSection } from './session/LeftPaneMessageSection'; import { LeftPaneContactSection } from './session/LeftPaneContactSection'; import { LeftPaneSettingSection } from './session/LeftPaneSettingSection'; import { SessionTheme } from '../state/ducks/SessionTheme'; -import { SessionExpiredWarning } from './session/network/SessionExpiredWarning'; import { getFocusedSection } from '../state/selectors/section'; import { useSelector } from 'react-redux'; import { getLeftPaneLists } from '../state/selectors/conversations'; @@ -24,11 +23,7 @@ export type RowRendererParamsType = { style: Object; }; -type Props = { - isExpired: boolean; -}; - -const InnerLeftPaneMessageSection = (props: { isExpired: boolean }) => { +const InnerLeftPaneMessageSection = () => { const showSearch = useSelector(isSearching); const searchTerm = useSelector(getQuery); @@ -38,15 +33,12 @@ const InnerLeftPaneMessageSection = (props: { isExpired: boolean }) => { // tslint:disable: use-simple-attributes return ( - <> - {props.isExpired && } - - + ); }; @@ -54,11 +46,11 @@ const InnerLeftPaneContactSection = () => { return ; }; -const LeftPaneSection = (props: { isExpired: boolean }) => { +const LeftPaneSection = () => { const focusedSection = useSelector(getFocusedSection); if (focusedSection === SectionType.Message) { - return ; + return ; } if (focusedSection === SectionType.Contact) { @@ -70,7 +62,7 @@ const LeftPaneSection = (props: { isExpired: boolean }) => { return null; }; -export const LeftPane = (props: Props) => { +export const LeftPane = () => { const theme = useSelector(getTheme); return ( @@ -79,7 +71,7 @@ export const LeftPane = (props: Props) => {
- +
diff --git a/ts/components/session/SessionInboxView.tsx b/ts/components/session/SessionInboxView.tsx index dd9305b63..9357b30bc 100644 --- a/ts/components/session/SessionInboxView.tsx +++ b/ts/components/session/SessionInboxView.tsx @@ -32,7 +32,6 @@ import { TimerOptionsArray, TimerOptionsState } from '../../state/ducks/timerOpt type State = { isInitialLoadComplete: boolean; - isExpired: boolean; }; export class SessionInboxView extends React.Component { @@ -42,19 +41,9 @@ export class SessionInboxView extends React.Component { super(props); this.state = { isInitialLoadComplete: false, - isExpired: false, }; void this.setupLeftPane(); - - // not reactified yet. this is a callback called once we were able to check for expiration of this Session version - window.extension.expired((expired: boolean) => { - if (expired) { - this.setState({ - isExpired: true, - }); - } - }); } public render() { @@ -78,7 +67,7 @@ export class SessionInboxView extends React.Component { } private renderLeftPane() { - return ; + return ; } private async setupLeftPane() { diff --git a/ts/components/session/network/SessionExpiredWarning.tsx b/ts/components/session/network/SessionExpiredWarning.tsx deleted file mode 100644 index bc20f1660..000000000 --- a/ts/components/session/network/SessionExpiredWarning.tsx +++ /dev/null @@ -1,28 +0,0 @@ -import React from 'react'; -import styled, { DefaultTheme } from 'styled-components'; - -const SessionExpiredWarningContainer = styled.div` - background: ${props => props.theme.colors.destructive}; - color: black; - padding: ${props => props.theme.common.margins.sm}; - margin: ${props => props.theme.common.margins.xs}; -`; - -const SessionExpiredWarningLink = styled.a` - color: black; -`; - -export const SessionExpiredWarning = () => { - return ( - -
{window.i18n('expiredWarning')}
- - {window.i18n('upgrade')} - -
- ); -}; diff --git a/ts/window.d.ts b/ts/window.d.ts index 9e25d58d5..c4a8c17ea 100644 --- a/ts/window.d.ts +++ b/ts/window.d.ts @@ -77,10 +77,6 @@ declare global { conversationKey: string; messageId?: string | undefined; }) => Promise; - extension: { - expired: (boolean) => void; - expiredStatus: () => boolean; - }; LokiPushNotificationServer: any; globalOnlineStatus: boolean; confirmationDialog: any;