{ description }
From 9431393bdaa107be1505a698963ac79eba25e917 Mon Sep 17 00:00:00 2001
From: Michael Telatynski <7t3chguy@gmail.com>
Date: Fri, 29 May 2020 19:59:47 +0100
Subject: [PATCH 46/50] Allow deferring of Update Toast until the next morning
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
---
src/BasePlatform.ts | 36 +++++++++++++++++++
.../views/settings/UpdateCheckButton.tsx | 2 --
src/toasts/UpdateToast.tsx | 6 ++++
3 files changed, 42 insertions(+), 2 deletions(-)
diff --git a/src/BasePlatform.ts b/src/BasePlatform.ts
index 0465b434d0..c5f58f7f0c 100644
--- a/src/BasePlatform.ts
+++ b/src/BasePlatform.ts
@@ -23,6 +23,7 @@ import BaseEventIndexManager from './indexing/BaseEventIndexManager';
import {ActionPayload} from "./dispatcher/payloads";
import {CheckUpdatesPayload} from "./dispatcher/payloads/CheckUpdatesPayload";
import {Action} from "./dispatcher/actions";
+import {hideToast as hideUpdateToast} from "./toasts/UpdateToast";
export enum UpdateCheckStatus {
Checking = "CHECKING",
@@ -32,6 +33,8 @@ export enum UpdateCheckStatus {
Ready = "READY",
}
+const UPDATE_DEFER_KEY = "mx_defer_update";
+
/**
* Base class for classes that provide platform-specific functionality
* eg. Setting an application badge or displaying notifications
@@ -74,12 +77,45 @@ export default abstract class BasePlatform {
}
startUpdateCheck() {
+ hideUpdateToast();
+ localStorage.removeItem(UPDATE_DEFER_KEY);
dis.dispatch({
action: Action.CheckUpdates,
status: UpdateCheckStatus.Checking,
});
}
+ /**
+ * Update the currently running app to the latest available version
+ * and replace this instance of the app with the new version.
+ */
+ installUpdate() {
+ }
+
+ /**
+ * Check if the version update has been deferred and that deferment is still in effect
+ * @param newVersion the version string to check
+ */
+ protected shouldShowUpdate(newVersion: string): boolean {
+ try {
+ const [version, deferUntil] = JSON.parse(localStorage.getItem(UPDATE_DEFER_KEY));
+ return newVersion !== version || Date.now() > deferUntil;
+ } catch (e) {
+ return true;
+ }
+ }
+
+ /**
+ * Ignore the pending update and don't prompt about this version
+ * until the next morning (8am).
+ */
+ deferUpdate(newVersion: string) {
+ const date = new Date(Date.now() + 24 * 60 * 60 * 1000);
+ date.setHours(8, 0, 0, 0); // set to next 8am
+ localStorage.setItem(UPDATE_DEFER_KEY, JSON.stringify([newVersion, date.getTime()]));
+ hideUpdateToast();
+ }
+
/**
* Returns true if the platform supports displaying
* notifications, otherwise false.
diff --git a/src/components/views/settings/UpdateCheckButton.tsx b/src/components/views/settings/UpdateCheckButton.tsx
index 3f7c11dfc8..10e0e29f31 100644
--- a/src/components/views/settings/UpdateCheckButton.tsx
+++ b/src/components/views/settings/UpdateCheckButton.tsx
@@ -18,7 +18,6 @@ import React, {useState} from "react";
import {UpdateCheckStatus} from "../../../BasePlatform";
import PlatformPeg from "../../../PlatformPeg";
-import {hideToast as hideUpdateToast} from "../../../toasts/UpdateToast";
import {useDispatcher} from "../../../hooks/useDispatcher";
import dis from "../../../dispatcher/dispatcher";
import {Action} from "../../../dispatcher/actions";
@@ -60,7 +59,6 @@ const UpdateCheckButton = () => {
const onCheckForUpdateClick = () => {
setState(null);
PlatformPeg.get().startUpdateCheck();
- hideUpdateToast();
};
useDispatcher(dis, ({action, ...params}) => {
diff --git a/src/toasts/UpdateToast.tsx b/src/toasts/UpdateToast.tsx
index 3d4b55a4ff..7a8d3671db 100644
--- a/src/toasts/UpdateToast.tsx
+++ b/src/toasts/UpdateToast.tsx
@@ -40,6 +40,10 @@ function installUpdate() {
}
export const showToast = (version: string, newVersion: string, releaseNotes?: string) => {
+ function onReject() {
+ PlatformPeg.get().deferUpdate(newVersion);
+ }
+
let onAccept;
let acceptLabel = _t("What's new?");
if (releaseNotes) {
@@ -79,6 +83,8 @@ export const showToast = (version: string, newVersion: string, releaseNotes?: st
description: _t("A new version of Riot is available!"),
acceptLabel,
onAccept,
+ rejectLabel: _t("Later"),
+ onReject,
},
component: GenericToast,
priority: 20,
From 0bbf971bac5e2c47909a84d9d95418ee3ce9ca2d Mon Sep 17 00:00:00 2001
From: Michael Telatynski <7t3chguy@gmail.com>
Date: Fri, 29 May 2020 20:50:47 +0100
Subject: [PATCH 47/50] Update src/dispatcher/actions.ts
Co-authored-by: Travis Ralston
---
src/dispatcher/actions.ts | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/dispatcher/actions.ts b/src/dispatcher/actions.ts
index c1d6fd5c54..7e76ea5ccb 100644
--- a/src/dispatcher/actions.ts
+++ b/src/dispatcher/actions.ts
@@ -50,8 +50,7 @@ export enum Action {
RecheckTheme = "recheck_theme",
/**
- * Response to manual update check, will fire multiple times during the update check.
+ * Provide status information for an ongoing update check. Should be used with a CheckUpdatesPayload.
*/
CheckUpdates = "check_updates",
}
-
From f3fedc5fc4f8315a83ed46ab3891eb25b7ab8e39 Mon Sep 17 00:00:00 2001
From: Matthew Hodgson
Date: Sat, 30 May 2020 00:42:23 +0100
Subject: [PATCH 48/50] fix url
---
code_style.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/code_style.md b/code_style.md
index 01c1f37146..8c8e40fa18 100644
--- a/code_style.md
+++ b/code_style.md
@@ -4,7 +4,7 @@ Matrix JavaScript/ECMAScript Style Guide
The intention of this guide is to make Matrix's JavaScript codebase clean,
consistent with other popular JavaScript styles and consistent with the rest of
the Matrix codebase. For reference, the Matrix Python style guide can be found
-at https://github.com/matrix-org/synapse/blob/master/docs/code_style.rst
+at https://github.com/matrix-org/synapse/blob/master/docs/code_style.md
This document reflects how we would like Matrix JavaScript code to look, with
acknowledgement that a significant amount of code is written to older
From 7750c95a028b8703fd9b4a685b08d599cdede3af Mon Sep 17 00:00:00 2001
From: Matthew Hodgson
Date: Sat, 30 May 2020 00:43:55 +0100
Subject: [PATCH 49/50] typoe
---
code_style.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/code_style.md b/code_style.md
index 8c8e40fa18..fe04d2cc3d 100644
--- a/code_style.md
+++ b/code_style.md
@@ -17,7 +17,7 @@ writing in modern ECMAScript and using a transpile step to generate the file
that applications can then include. There are significant benefits in being
able to use modern ECMAScript, although the tooling for doing so can be awkward
for library code, especially with regard to translating source maps and line
-number throgh from the original code to the final application.
+number through from the original code to the final application.
General Style
-------------
From 5b31fdd30846c7b3d56c08ecabc09d56584188ec Mon Sep 17 00:00:00 2001
From: Michael Telatynski <7t3chguy@gmail.com>
Date: Sat, 30 May 2020 12:36:17 +0100
Subject: [PATCH 50/50] remove stale references to MatrixToolbar
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
---
.eslintignore.errorfiles | 1 -
test/skinned-sdk.js | 1 -
2 files changed, 2 deletions(-)
diff --git a/.eslintignore.errorfiles b/.eslintignore.errorfiles
index 7e88ebff7f..db12611ade 100644
--- a/.eslintignore.errorfiles
+++ b/.eslintignore.errorfiles
@@ -14,7 +14,6 @@ src/components/views/elements/AddressSelector.js
src/components/views/elements/DirectorySearchBox.js
src/components/views/elements/MemberEventListSummary.js
src/components/views/elements/UserSelector.js
-src/components/views/globals/MatrixToolbar.js
src/components/views/globals/NewVersionBar.js
src/components/views/messages/MFileBody.js
src/components/views/messages/TextualBody.js
diff --git a/test/skinned-sdk.js b/test/skinned-sdk.js
index bc13d78815..876a188cc0 100644
--- a/test/skinned-sdk.js
+++ b/test/skinned-sdk.js
@@ -16,7 +16,6 @@ const components = {};
components['structures.LeftPanel'] = stubComponent();
components['structures.RightPanel'] = stubComponent();
components['structures.RoomDirectory'] = stubComponent();
-components['views.globals.MatrixToolbar'] = stubComponent();
components['views.globals.GuestWarningBar'] = stubComponent();
components['views.globals.NewVersionBar'] = stubComponent();
components['views.elements.Spinner'] = stubComponent({displayName: 'Spinner'});