From 2eac8f48d623d717c4e5331ef79fe1b8d9061dfd Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Wed, 16 May 2018 21:37:35 +0200 Subject: [PATCH 1/9] Workaround IOS focus bug when clicking on buttons --- .../client/components/rte/components/Button.js | 11 ++--------- .../client/components/rte/factories/createToggle.js | 12 ++++++++++++ 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/plugins/talk-plugin-rich-text/client/components/rte/components/Button.js b/plugins/talk-plugin-rich-text/client/components/rte/components/Button.js index f99648cb7..fd5d451a1 100644 --- a/plugins/talk-plugin-rich-text/client/components/rte/components/Button.js +++ b/plugins/talk-plugin-rich-text/client/components/rte/components/Button.js @@ -7,21 +7,17 @@ class Button extends React.Component { render() { const { className, - title, - onClick, children, active, activeClassName, - disabled, + ...rest } = this.props; return ( @@ -32,11 +28,8 @@ class Button extends React.Component { Button.propTypes = { className: PropTypes.string, activeClassName: PropTypes.string, - title: PropTypes.string, - onClick: PropTypes.func, children: PropTypes.node, active: PropTypes.bool, - disabled: PropTypes.bool, }; export default Button; diff --git a/plugins/talk-plugin-rich-text/client/components/rte/factories/createToggle.js b/plugins/talk-plugin-rich-text/client/components/rte/factories/createToggle.js index 028757222..59b75fdf2 100644 --- a/plugins/talk-plugin-rich-text/client/components/rte/factories/createToggle.js +++ b/plugins/talk-plugin-rich-text/client/components/rte/factories/createToggle.js @@ -1,6 +1,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import Button from '../components/Button'; +import bowser from 'bowser'; /** * createToggle creates a button that can be active, inactive or disabled @@ -32,7 +33,17 @@ const createToggle = ( this.execCommand(); }; + // Detect whether there was focus on the RTE before the click. + hadFocusBeforeClick = false; + handleMouseDown = () => (this.hadFocusBeforeClick = this.props.api.focused); + handleClick = () => { + // Skip IOS when the focus was not there before. + // IOS fails to focus to the RTE correctly and scrolls to nirvana. + // See https://www.pivotaltracker.com/story/show/157607216 + if (!this.hadFocusBeforeClick && bowser.ios) { + return; + } this.props.api.focus(); this.formatToggle(); this.props.api.focus(); @@ -62,6 +73,7 @@ const createToggle = ( From ebcff4d95e378f46fc0b1b693e9bb8250a86a490 Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Thu, 17 May 2018 18:58:01 -0600 Subject: [PATCH 8/9] patched migration bugs --- models/schema/user.js | 10 +++++++++ services/actions.js | 49 +++++++++++++++++++------------------------ 2 files changed, 32 insertions(+), 27 deletions(-) diff --git a/models/schema/user.js b/models/schema/user.js index a4ccfd185..a27b8dc39 100644 --- a/models/schema/user.js +++ b/models/schema/user.js @@ -339,6 +339,11 @@ User.virtual('banned') }) .set(function(status) { this.status.banned.status = status; + + if (!this.status.banned.history) { + this.status.banned.history = []; + } + this.status.banned.history.push({ status, created_at: new Date(), @@ -357,6 +362,11 @@ User.virtual('suspended') }) .set(function(until) { this.status.suspension.until = until; + + if (!this.status.suspension.history) { + this.status.suspension.history = []; + } + this.status.suspension.history.push({ until, created_at: new Date(), diff --git a/services/actions.js b/services/actions.js index 1c95e5128..790adc6a0 100644 --- a/services/actions.js +++ b/services/actions.js @@ -2,7 +2,7 @@ const ActionModel = require('../models/action'); const CommentModel = require('../models/comment'); const UserModel = require('../models/user'); const _ = require('lodash'); -const errors = require('../errors'); +const { ErrAlreadyExists } = require('../errors'); const incrActionCounts = async (action, value) => { const ACTION_TYPE = action.action_type.toLowerCase(); @@ -41,35 +41,30 @@ const incrActionCounts = async (action, value) => { * @param {object} update the update operation for the mongo findOneAndUpdate op * @param {object} options the options operation for the mongo findOneAndUpdate op */ -const findOnlyOneAndUpdate = async (query, update, options = {}) => - new Promise((resolve, reject) => { - ActionModel.findOneAndUpdate( - query, - update, - Object.assign({}, options, { - // Use raw result to get `updatedExisting`. - passRawResult: true, +const findOnlyOneAndUpdate = async (query, update, options = {}) => { + const raw = await ActionModel.findOneAndUpdate( + query, + update, + Object.assign({}, options, { + // Use raw result to get `updatedExisting`. + rawResult: true, - // Ensure that if it's new, we return the new object created. - new: true, + // Ensure that if it's new, we return the new object created. + new: true, - // Perform an upsert in the event that this doesn't exist. - upsert: true, + // Perform an upsert in the event that this doesn't exist. + upsert: true, - // Set the default values if not provided based on the mongoose models. - setDefaultsOnInsert: true, - }), - (err, doc, raw) => { - if (err) { - return reject(err); - } - if (raw.lastErrorObject.updatedExisting) { - return reject(new errors.ErrAlreadyExists(raw.value)); - } - return resolve(raw.value); - } - ); - }); + // Set the default values if not provided based on the mongoose models. + setDefaultsOnInsert: true, + }) + ); + if (raw.lastErrorObject.updatedExisting) { + throw new ErrAlreadyExists(raw.value); + } + + return raw.value; +}; module.exports = class ActionsService { /** From ffa6b99d09aadc14e4c6109cdce3148cad5ff0ac Mon Sep 17 00:00:00 2001 From: Mendel Konikov Date: Fri, 18 May 2018 12:32:24 -0400 Subject: [PATCH 9/9] Wrap els in div --- .../client/components/DeleteMyAccount.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/plugins/talk-plugin-profile-data/client/components/DeleteMyAccount.js b/plugins/talk-plugin-profile-data/client/components/DeleteMyAccount.js index 6eae91043..c2055a16e 100644 --- a/plugins/talk-plugin-profile-data/client/components/DeleteMyAccount.js +++ b/plugins/talk-plugin-profile-data/client/components/DeleteMyAccount.js @@ -64,15 +64,17 @@ class DeleteMyAccount extends React.Component { {t('delete_request.delete_my_account_description')}

{scheduledDeletionDate ? ( -

- {t( +

+

+ {t( 'delete_request.already_submitted_request_description', moment(scheduledDeletionDate).format('MMM Do YYYY, h:mm:ss a') )} -

- +

+ +
) : (