diff --git a/r2/r2/controllers/api.py b/r2/r2/controllers/api.py index 6aad18272b..10cb03ca69 100644 --- a/r2/r2/controllers/api.py +++ b/r2/r2/controllers/api.py @@ -1615,9 +1615,10 @@ def POST_editusertext(self, form, jquery, item, text): return removed_mentions = None + original_text = item.body if isinstance(item, Comment): kind = 'comment' - removed_mentions = set(extract_user_mentions(item.body)) - \ + removed_mentions = set(extract_user_mentions(original_text)) - \ set(extract_user_mentions(text)) item.body = text elif isinstance(item, Link): @@ -1648,6 +1649,9 @@ def POST_editusertext(self, form, jquery, item, text): amqp.add_item('usertext_edited', item._fullname) + hooks.get_hook("thing.edit").call( + thing=item, original_text=original_text) + # new mentions are subject to more constraints, handled in butler_q if removed_mentions: queries.unnotify(item, list(Account._names_to_ids( diff --git a/r2/r2/public/static/js/ui.js b/r2/r2/public/static/js/ui.js index ef8ee761b5..b17167ff02 100644 --- a/r2/r2/public/static/js/ui.js +++ b/r2/r2/public/static/js/ui.js @@ -10,9 +10,7 @@ r.ui.init = function() { } // mobile suggest infobar - var smallScreen = window.matchMedia - ? matchMedia('(max-device-width: 700px)').matches - : $(window).width() < 700, + var smallScreen = r.ui.isSmallScreen(), onFrontPage = $.url().attr('path') == '/' if (smallScreen && onFrontPage && r.config.renderstyle != 'compact') { var infobar = $('
') @@ -32,7 +30,9 @@ r.ui.init = function() { $(el).data('SubredditSubmitText', new r.ui.SubredditSubmitText({el: el})) }) - if (r.config.new_window) { + /* Open links in new tabs if they have the preference set or are logged out + * and on a "large" screen. */ + if (r.config.new_window && (r.config.logged || !smallScreen)) { $(document.body).on('click', 'a.may-blank, .may-blank-within a', function() { if (!this.target) { this.target = '_blank' @@ -48,6 +48,13 @@ r.ui.init = function() { r.ui.initTimings() } +r.ui.isSmallScreen = function() { + return window.matchMedia + // 736px is the width of the iPhone 6+. + ? matchMedia('(max-device-width: 736px)').matches + : $(window).width() < 736; +} + r.ui.TimeTextScrollListener = r.ScrollUpdater.extend({ initialize: function(options) { this.timeText = options.timeText