From 383eee4db93863ba28584d85b328ae3fd11aadc2 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Mon, 16 Oct 2017 15:43:48 +0200 Subject: [PATCH] Fixed small twitter ui/usability issues. --- .../app/controllers/_channel/twitter.coffee | 25 ++++++++++++------- app/models/channel/driver/twitter.rb | 9 +++++-- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/app/assets/javascripts/app/controllers/_channel/twitter.coffee b/app/assets/javascripts/app/controllers/_channel/twitter.coffee index 2e756c0f1..b4a95a770 100644 --- a/app/assets/javascripts/app/controllers/_channel/twitter.coffee +++ b/app/assets/javascripts/app/controllers/_channel/twitter.coffee @@ -211,6 +211,8 @@ class AccountEdit extends App.ControllerModal ) addSearchTerm = => + params = @getParams() + @searchTerms = params.search || [] @searchTerms.push term: '' group_id: '' @@ -219,6 +221,8 @@ class AccountEdit extends App.ControllerModal removeSearchTerm = (event) => index = $(event.currentTarget).attr('data-index') + params = @getParams() + @searchTerms = params.search || [] @searchTerms.splice(index, 1) renderSearchTerms() @@ -249,13 +253,7 @@ class AccountEdit extends App.ControllerModal content.find('.js-directMessagesGroup').replaceWith createGroupSelection(@channel.options.sync.direct_messages.group_id, 'direct_messages') content - onClosed: => - return if !@isChanged - @isChanged = false - @load() - - onSubmit: (e) => - @formDisable(e) + getParams: => params = @formParams() search = [] position = 0 @@ -269,12 +267,21 @@ class AccountEdit extends App.ControllerModal position += 1 else search.push params.search + params.search = search if params.track_retweets params.track_retweets = true else params.track_retweets = false - params.search = search - @channel.options.sync = params + params + + onClosed: => + return if !@isChanged + @isChanged = false + @load() + + onSubmit: (e) => + @formDisable(e) + @channel.options.sync = @getParams() @ajax( id: 'channel_twitter_update' type: 'POST' diff --git a/app/models/channel/driver/twitter.rb b/app/models/channel/driver/twitter.rb index 0780b7d2c..34a2b3e27 100644 --- a/app/models/channel/driver/twitter.rb +++ b/app/models/channel/driver/twitter.rb @@ -222,6 +222,8 @@ returns if sync['search'] hashtags = [] sync['search'].each do |item| + next if item['term'].blank? + next if item['group_id'].blank? hashtags.push item['term'] end filter[:track] = hashtags.join(',') @@ -253,7 +255,7 @@ returns next if @stream_client.tweet_limit_reached(tweet, 2) # check if it's mention - if sync['mentions'] && sync['mentions']['group_id'] != '' + if sync['mentions'] && sync['mentions']['group_id'].present? hit = false if tweet.user_mentions tweet.user_mentions.each do |user| @@ -272,6 +274,8 @@ returns if sync['search'] && tweet.hashtags hit = false sync['search'].each do |item| + next if item['term'].blank? + next if item['group_id'].blank? tweet.hashtags.each do |hashtag| next if item['term'] !~ /^#/ if item['term'].sub(/^#/, '') == hashtag.text @@ -290,7 +294,8 @@ returns hit = false body = tweet.text sync['search'].each do |item| - next if item['term'] =~ /^#/ + next if item['term'].blank? + next if item['group_id'].blank? if body =~ /#{item['term']}/ hit = item end