From 025f7bb223daf88c89649251c28751b36197bff3 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Thu, 22 Dec 2016 11:23:30 +0100 Subject: [PATCH 1/2] Fix notifications reducer bug --- app/assets/javascripts/components/actions/notifications.jsx | 4 ++-- app/assets/javascripts/components/reducers/accounts.jsx | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/components/actions/notifications.jsx b/app/assets/javascripts/components/actions/notifications.jsx index a03f88af13..6a8b1b05b6 100644 --- a/app/assets/javascripts/components/actions/notifications.jsx +++ b/app/assets/javascripts/components/actions/notifications.jsx @@ -76,7 +76,7 @@ export function refreshNotificationsSuccess(notifications, next) { type: NOTIFICATIONS_REFRESH_SUCCESS, notifications, accounts: notifications.map(item => item.account), - statuses: notifications.map(item => item.status), + statuses: notifications.map(item => item.status).filter(status => !!status), next }; }; @@ -120,7 +120,7 @@ export function expandNotificationsSuccess(notifications, next) { type: NOTIFICATIONS_EXPAND_SUCCESS, notifications, accounts: notifications.map(item => item.account), - statuses: notifications.map(item => item.status), + statuses: notifications.map(item => item.status).filter(status => !!status), next }; }; diff --git a/app/assets/javascripts/components/reducers/accounts.jsx b/app/assets/javascripts/components/reducers/accounts.jsx index 52be648b3e..982e63073b 100644 --- a/app/assets/javascripts/components/reducers/accounts.jsx +++ b/app/assets/javascripts/components/reducers/accounts.jsx @@ -78,9 +78,10 @@ export default function accounts(state = initialState, action) { case FAVOURITES_FETCH_SUCCESS: case COMPOSE_SUGGESTIONS_READY: case SEARCH_SUGGESTIONS_READY: + return normalizeAccounts(state, action.accounts); case NOTIFICATIONS_REFRESH_SUCCESS: case NOTIFICATIONS_EXPAND_SUCCESS: - return normalizeAccounts(state, action.accounts); + return normalizeAccountsFromStatuses(normalizeAccounts(state, action.accounts), action.statuses); case TIMELINE_REFRESH_SUCCESS: case TIMELINE_EXPAND_SUCCESS: case ACCOUNT_TIMELINE_FETCH_SUCCESS: From 3caf0cfb03841bbd646591ca9bc536ee7d9be918 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Thu, 22 Dec 2016 11:34:05 +0100 Subject: [PATCH 2/2] Ensure that reblogs and favs always refer to the original status rather than a reblog wrapper --- app/models/favourite.rb | 4 ++++ app/models/status.rb | 1 + 2 files changed, 5 insertions(+) diff --git a/app/models/favourite.rb b/app/models/favourite.rb index 541ca08314..2fc3d18cde 100644 --- a/app/models/favourite.rb +++ b/app/models/favourite.rb @@ -28,4 +28,8 @@ class Favourite < ApplicationRecord def target thread end + + before_validation do + self.status = status.reblog if status.reblog? + end end diff --git a/app/models/status.rb b/app/models/status.rb index e87828e328..76ada52275 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -160,6 +160,7 @@ class Status < ApplicationRecord before_validation do text.strip! + self.reblog = reblog.reblog if reblog? && reblog.reblog? self.in_reply_to_account_id = thread.account_id if reply? end end