remove expire warning. app asks to update on app start

pull/1804/head
Audric Ackermann 4 years ago
parent 3ee8e8e7cc
commit 8ab8444222
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4

@ -54,7 +54,6 @@
<script type="text/javascript" src="js/chromium.js"></script>
<script type="text/javascript" src="js/registration.js"></script>
<script type="text/javascript" src="js/expire.js"></script>
<script type="text/javascript" src="js/views/react_wrapper_view.js"></script>
<script type="text/javascript" src="js/views/whisper_view.js"></script>

@ -54,7 +54,6 @@
<script type="text/javascript" src="js/chromium.js"></script>
<script type="text/javascript" src="js/registration.js"></script>
<script type="text/javascript" src="js/expire.js"></script>
<script type="text/javascript" src="js/views/react_wrapper_view.js"></script>
<script type="text/javascript" src="js/views/whisper_view.js"></script>

@ -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);
};
})();

@ -28,8 +28,6 @@
<script type="text/javascript" src="../js/database.js" data-cover></script>
<script type="text/javascript" src="../js/storage.js" data-cover></script>
<script type="text/javascript" src="../js/libtextsecure.js" data-cover></script>
<!-- needs the network comms libraries to work -->
<script type="text/javascript" src="../js/expire.js" data-cover></script>
<script type="text/javascript" src="../js/expiring_messages.js" data-cover></script>
<script type="text/javascript" src="../js/notifications.js" data-cover></script>

@ -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 && <SessionExpiredWarning />}
<LeftPaneMessageSection
conversations={lists?.conversations || []}
contacts={lists?.contacts || []}
searchResults={searchResults}
searchTerm={searchTerm}
/>
</>
<LeftPaneMessageSection
conversations={lists?.conversations || []}
contacts={lists?.contacts || []}
searchResults={searchResults}
searchTerm={searchTerm}
/>
);
};
@ -54,11 +46,11 @@ const InnerLeftPaneContactSection = () => {
return <LeftPaneContactSection />;
};
const LeftPaneSection = (props: { isExpired: boolean }) => {
const LeftPaneSection = () => {
const focusedSection = useSelector(getFocusedSection);
if (focusedSection === SectionType.Message) {
return <InnerLeftPaneMessageSection isExpired={props.isExpired} />;
return <InnerLeftPaneMessageSection />;
}
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) => {
<ActionsPanel />
<div className="module-left-pane">
<LeftPaneSection isExpired={props.isExpired} />
<LeftPaneSection />
</div>
</div>
</SessionTheme>

@ -32,7 +32,6 @@ import { TimerOptionsArray, TimerOptionsState } from '../../state/ducks/timerOpt
type State = {
isInitialLoadComplete: boolean;
isExpired: boolean;
};
export class SessionInboxView extends React.Component<any, State> {
@ -42,19 +41,9 @@ export class SessionInboxView extends React.Component<any, State> {
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<any, State> {
}
private renderLeftPane() {
return <LeftPane isExpired={this.state.isExpired} />;
return <LeftPane />;
}
private async setupLeftPane() {

@ -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 (
<SessionExpiredWarningContainer>
<div>{window.i18n('expiredWarning')}</div>
<SessionExpiredWarningLink
href={'https://getsession.org'}
target="_blank"
rel="noopener noreferrer"
>
{window.i18n('upgrade')}
</SessionExpiredWarningLink>
</SessionExpiredWarningContainer>
);
};

4
ts/window.d.ts vendored

@ -77,10 +77,6 @@ declare global {
conversationKey: string;
messageId?: string | undefined;
}) => Promise<void>;
extension: {
expired: (boolean) => void;
expiredStatus: () => boolean;
};
LokiPushNotificationServer: any;
globalOnlineStatus: boolean;
confirmationDialog: any;

Loading…
Cancel
Save