From e8494c3dc78f7e7919feb24f789724959ad0f846 Mon Sep 17 00:00:00 2001
From: David Baker <dave@matrix.org>
Date: Wed, 2 Nov 2016 19:20:11 +0000
Subject: [PATCH 1/4] Split NewVersionBar release notes / changelog

and change the class to use React createClass syntax while I'm at
it, rather than a completely different third style we use nowhere
else in the project.
---
 src/components/views/globals/NewVersionBar.js | 117 ++++++++++--------
 1 file changed, 65 insertions(+), 52 deletions(-)

diff --git a/src/components/views/globals/NewVersionBar.js b/src/components/views/globals/NewVersionBar.js
index 3ae95804..bca4e3de 100644
--- a/src/components/views/globals/NewVersionBar.js
+++ b/src/components/views/globals/NewVersionBar.js
@@ -16,8 +16,8 @@ limitations under the License.
 
 'use strict';
 
-var React = require('react');
-var sdk = require('matrix-react-sdk');
+import React from 'react';
+import sdk from 'matrix-react-sdk';
 import Modal from 'matrix-react-sdk/lib/Modal';
 import PlatformPeg from 'matrix-react-sdk/lib/PlatformPeg';
 
@@ -30,58 +30,71 @@ function checkVersion(ver) {
     return parts[0] == 'vector' && parts[2] == 'react' && parts[4] == 'js';
 }
 
-export default function NewVersionBar(props) {
-    const onChangelogClicked = () => {
-        if (props.releaseNotes) {
-            const QuestionDialog = sdk.getComponent('dialogs.QuestionDialog');
-            Modal.createDialog(QuestionDialog, {
-                title: "What's New",
-                description: <pre className="changelog_text">{props.releaseNotes}</pre>,
-                button: "Update",
-                onFinished: (update) => {
-                    if(update && PlatformPeg.get()) {
-                        PlatformPeg.get().installUpdate();
-                    }
-                }
-            });
-        } else {
-            const ChangelogDialog = sdk.getComponent('dialogs.ChangelogDialog');
-            Modal.createDialog(ChangelogDialog, {
-                version: props.version,
-                newVersion: props.newVersion,
-                releaseNotes: releaseNotes,
-                onFinished: (update) => {
-                    if(update && PlatformPeg.get()) {
-                        PlatformPeg.get().installUpdate();
-                    }
-                }
-            });
+export default React.createClass({
+    propTypes: {
+        version: React.PropTypes.string.isRequired,
+        newVersion: React.PropTypes.string.isRequired,
+        releaseNotes: React.PropTypes.string,
+    },
+
+    onChangelogClicked: function() {
+        // If we have release notes to display, we display them. Otherwise,
+        // we display the Changelog Dialog which takes two versions and
+        // automatically tells you what's changed (provided the versions
+        // are in the right format)
+        if (this.props.releaseNotes) {
+            this.displayReleaseNotes(this.props.releaseNotes);
+        } else if (checkVersion(this.props.version) && checkVersion(this.props.newVersion)) {
+            this.displayChangelog();
         }
-    };
+    },
 
-    const onUpdateClicked = () => {
+    displayReleaseNotes: function(releaseNotes) {
+        const QuestionDialog = sdk.getComponent('dialogs.QuestionDialog');
+        Modal.createDialog(QuestionDialog, {
+            title: "What's New",
+            description: <pre className="changelog_text">{releaseNotes}</pre>,
+            button: "Update",
+            onFinished: (update) => {
+                if(update && PlatformPeg.get()) {
+                    PlatformPeg.get().installUpdate();
+                }
+            }
+        });
+    },
+
+    displayChangelog: function() {
+        const ChangelogDialog = sdk.getComponent('dialogs.ChangelogDialog');
+        Modal.createDialog(ChangelogDialog, {
+            version: this.props.version,
+            newVersion: this.props.newVersion,
+            onFinished: (update) => {
+                if(update && PlatformPeg.get()) {
+                    PlatformPeg.get().installUpdate();
+                }
+            }
+        });
+    },
+
+    onUpdateClicked: function() {
         PlatformPeg.get().installUpdate();
-    };
+    },
 
-    let action_button;
-    if (props.releaseNotes || (checkVersion(props.version) && checkVersion(props.newVersion))) {
-        action_button = <button className="mx_MatrixToolbar_action" onClick={onChangelogClicked}>What's new?</button>;
-    } else if (PlatformPeg.get()) {
-        action_button = <button className="mx_MatrixToolbar_action" onClick={onUpdateClicked}>Update</button>;
-    }
-    return (
-        <div className="mx_MatrixToolbar">
-            <img className="mx_MatrixToolbar_warning" src="img/warning.svg" width="24" height="23" alt="/!\"/>
-            <div className="mx_MatrixToolbar_content">
-                A new version of Riot is available.
+    render: function() {
+        let action_button;
+        if (this.props.releaseNotes || (checkVersion(this.props.version) && checkVersion(this.props.newVersion))) {
+            action_button = <button className="mx_MatrixToolbar_action" onClick={this.onChangelogClicked}>What's new?</button>;
+        } else if (PlatformPeg.get()) {
+            action_button = <button className="mx_MatrixToolbar_action" onClick={this.onUpdateClicked}>Update</button>;
+        }
+        return (
+            <div className="mx_MatrixToolbar">
+                <img className="mx_MatrixToolbar_warning" src="img/warning.svg" width="24" height="23" alt="/!\"/>
+                <div className="mx_MatrixToolbar_content">
+                    A new version of Riot is available.
+                </div>
+                {action_button}
             </div>
-            {action_button}
-        </div>
-    );
-}
-
-NewVersionBar.propTypes = {
-    version: React.PropTypes.string.isRequired,
-    newVersion: React.PropTypes.string.isRequired,
-    releaseNotes: React.PropTypes.string,
-};
+        );
+    }
+});

From 108af83ae815be6776e70b20f37f5107f29067fe Mon Sep 17 00:00:00 2001
From: David Baker <dave@matrix.org>
Date: Thu, 3 Nov 2016 11:43:50 +0000
Subject: [PATCH 2/4] Just bind the right function to the button

rather than deciding in onChangelogClicked
---
 src/components/views/globals/NewVersionBar.js | 22 +++++++------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/components/views/globals/NewVersionBar.js b/src/components/views/globals/NewVersionBar.js
index bca4e3de..36d6bc71 100644
--- a/src/components/views/globals/NewVersionBar.js
+++ b/src/components/views/globals/NewVersionBar.js
@@ -37,18 +37,6 @@ export default React.createClass({
         releaseNotes: React.PropTypes.string,
     },
 
-    onChangelogClicked: function() {
-        // If we have release notes to display, we display them. Otherwise,
-        // we display the Changelog Dialog which takes two versions and
-        // automatically tells you what's changed (provided the versions
-        // are in the right format)
-        if (this.props.releaseNotes) {
-            this.displayReleaseNotes(this.props.releaseNotes);
-        } else if (checkVersion(this.props.version) && checkVersion(this.props.newVersion)) {
-            this.displayChangelog();
-        }
-    },
-
     displayReleaseNotes: function(releaseNotes) {
         const QuestionDialog = sdk.getComponent('dialogs.QuestionDialog');
         Modal.createDialog(QuestionDialog, {
@@ -82,8 +70,14 @@ export default React.createClass({
 
     render: function() {
         let action_button;
-        if (this.props.releaseNotes || (checkVersion(this.props.version) && checkVersion(this.props.newVersion))) {
-            action_button = <button className="mx_MatrixToolbar_action" onClick={this.onChangelogClicked}>What's new?</button>;
+        // If we have release notes to display, we display them. Otherwise,
+        // we display the Changelog Dialog which takes two versions and
+        // automatically tells you what's changed (provided the versions
+        // are in the right format)
+        if (this.props.releaseNotes) {
+            action_button = <button className="mx_MatrixToolbar_action" onClick={this.displayReleaseNotes}>What's new?</button>;
+        } else if (checkVersion(this.props.version) && checkVersion(this.props.newVersion)) {
+            action_button = <button className="mx_MatrixToolbar_action" onClick={this.displayChangelog}>What's new?</button>;
         } else if (PlatformPeg.get()) {
             action_button = <button className="mx_MatrixToolbar_action" onClick={this.onUpdateClicked}>Update</button>;
         }

From 3bcb447e039d71d5c4d651bca1eeb63f12a90044 Mon Sep 17 00:00:00 2001
From: David Baker <dave@matrix.org>
Date: Thu, 3 Nov 2016 11:48:49 +0000
Subject: [PATCH 3/4] Fix copyright

---
 src/vector/platform/WebPlatform.js | 3 ++-
 src/vector/platform/index.js       | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/vector/platform/WebPlatform.js b/src/vector/platform/WebPlatform.js
index 3477fc8b..f4adbd5d 100644
--- a/src/vector/platform/WebPlatform.js
+++ b/src/vector/platform/WebPlatform.js
@@ -1,7 +1,8 @@
 // @flow
 
 /*
-Copyright 2016 Aviral Dasgupta and OpenMarket Ltd
+Copyright 2016 Aviral Dasgupta
+Copyright 2016 OpenMarket Ltd
 
 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
diff --git a/src/vector/platform/index.js b/src/vector/platform/index.js
index c0f17ae9..741f1df0 100644
--- a/src/vector/platform/index.js
+++ b/src/vector/platform/index.js
@@ -1,7 +1,8 @@
 // @flow
 
 /*
-Copyright 2016 Aviral Dasgupta and OpenMarket Ltd
+Copyright 2016 Aviral Dasgupta
+Copyright 2016 OpenMarket Ltd
 
 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.

From f1b72dfa098a5e896fa69e0100749271325a5d7c Mon Sep 17 00:00:00 2001
From: David Baker <dave@matrix.org>
Date: Thu, 3 Nov 2016 11:51:41 +0000
Subject: [PATCH 4/4] Fix copyright

---
 src/vector/platform/VectorBasePlatform.js | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/vector/platform/VectorBasePlatform.js b/src/vector/platform/VectorBasePlatform.js
index a988a4c7..d2ed8c34 100644
--- a/src/vector/platform/VectorBasePlatform.js
+++ b/src/vector/platform/VectorBasePlatform.js
@@ -1,7 +1,8 @@
 // @flow
 
 /*
-Copyright 2016 Aviral Dasgupta and OpenMarket Ltd
+Copyright 2016 Aviral Dasgupta
+Copyright 2016 OpenMarket Ltd
 
 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.