Skip to content
This repository has been archived by the owner on Jan 27, 2020. It is now read-only.

Commit

Permalink
Merge pull request mastodon#378 from pixiv/renewal_notification_of_ge…
Browse files Browse the repository at this point in the history
…nerating_mv

Fix notification of generating mv
  • Loading branch information
abcang committed Oct 11, 2017
2 parents af4778b + e9e3f05 commit 5ac0d28
Show file tree
Hide file tree
Showing 14 changed files with 63 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/controllers/settings/preferences_controller.rb
Expand Up @@ -37,7 +37,7 @@ def user_settings_params
:setting_boost_modal,
:setting_delete_modal,
:setting_auto_play_gif,
notification_emails: %i(follow follow_request reblog favourite mention digest),
notification_emails: %i(follow follow_request reblog favourite mention digest video_preparation_error video_preparation_success),
interactions: %i(must_be_follower must_be_following)
)
end
Expand Down
2 changes: 2 additions & 0 deletions app/javascript/mastodon/locales/en.json
Expand Up @@ -109,6 +109,8 @@
"notification.follow": "{name} followed you",
"notification.mention": "{name} mentioned you",
"notification.reblog": "{name} boosted your status",
"notification.video_preparation_error": "The video generation for your track was failed",
"notification.video_preparation_success": "The video for your track was generated",
"notifications.clear": "Clear notifications",
"notifications.clear_confirmation": "Are you sure you want to permanently clear all your notifications?",
"notifications.column_settings.alert": "Desktop notifications",
Expand Down
2 changes: 2 additions & 0 deletions app/javascript/mastodon/locales/ja.json
Expand Up @@ -110,6 +110,8 @@
"notification.follow": "{name}さんにフォローされました",
"notification.mention": "{name}さんがあなたに返信しました",
"notification.reblog": "{name}さんがあなたのトゥートをブーストしました",
"notification.video_preparation_error": "トラックの動画の生成に失敗しました",
"notification.video_preparation_success": "トラックの動画の生成が完了しました",
"notifications.clear": "通知を消去",
"notifications.clear_confirmation": "本当に通知を消去しますか?",
"notifications.column_settings.alert": "デスクトップ通知",
Expand Down
4 changes: 4 additions & 0 deletions app/javascript/mastodon/reducers/accounts.js
Expand Up @@ -47,6 +47,10 @@ import { STORE_HYDRATE } from '../actions/store';
import Immutable from 'immutable';

const normalizeAccount = (state, account) => {
if (!account) {
return state;
}

account = { ...account };

delete account.followers_count;
Expand Down
16 changes: 11 additions & 5 deletions app/javascript/mastodon/reducers/accounts_counters.js
Expand Up @@ -48,11 +48,17 @@ import {
import { STORE_HYDRATE } from '../actions/store';
import Immutable from 'immutable';

const normalizeAccount = (state, account) => state.set(account.id, Immutable.fromJS({
followers_count: account.followers_count,
following_count: account.following_count,
statuses_count: account.statuses_count,
}));
const normalizeAccount = (state, account) => {
if (!account) {
return state;
}

return state.set(account.id, Immutable.fromJS({
followers_count: account.followers_count,
following_count: account.following_count,
statuses_count: account.statuses_count,
}));
};

const normalizeAccounts = (state, accounts) => {
accounts.forEach(account => {
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/mastodon/reducers/notifications.js
Expand Up @@ -25,7 +25,7 @@ const initialState = Immutable.Map({
const notificationToMap = notification => Immutable.Map({
id: notification.id,
type: notification.type,
account: notification.account.id,
account: notification.account && notification.account.id,
status: notification.status ? notification.status.id : null,
});

Expand Down
Expand Up @@ -69,10 +69,34 @@ export default class Notification extends ImmutablePureComponent {
);
}

renderVideoPreparationSuccess (notification) {
const prepend = (
<div className='prepend-inline'>
<FormattedMessage id='notification.video_preparation_success' defaultMessage='The video for your track was generated' />
</div>
);

return (
<StatusContainer id={notification.get('status')} prepend={prepend} muted withDismiss />
);
}

renderVideoPreparationError (notification) {
const prepend = (
<div className='prepend-inline'>
<FormattedMessage id='notification.video_preparation_error' defaultMessage='The video generation for your track was failed' />
</div>
);

return (
<StatusContainer id={notification.get('status')} prepend={prepend} muted withDismiss />
);
}

render () {
const { notification } = this.props;
const account = notification.get('account');
const link = (
const link = account && (
<Link to={`/@${account.get('acct')}`}>
<DisplayName account={account} />
</Link>
Expand All @@ -87,6 +111,10 @@ export default class Notification extends ImmutablePureComponent {
return this.renderFavourite(notification, link);
case 'reblog':
return this.renderReblog(notification, link);
case 'video_preparation_success':
return this.renderVideoPreparationSuccess(notification);
case 'video_preparation_error':
return this.renderVideoPreparationError(notification);
}

return null;
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/pawoo_music/reducers/acct_map.js
Expand Up @@ -46,7 +46,7 @@ import {
import { STORE_HYDRATE } from '../../mastodon/actions/store';
import Immutable from 'immutable';

const normalizeAccount = (state, account) => state.set(account.acct, account.id);
const normalizeAccount = (state, account) => account ? state.set(account.acct, account.id) : state;

const normalizeAccounts = (state, accounts) => {
accounts.forEach(account => {
Expand Down
2 changes: 1 addition & 1 deletion app/models/notification.rb
Expand Up @@ -85,7 +85,7 @@ def activity_types_from_types(types)
end
end

before_destroy :destroy_activity, if: ->(notification) { notification.type == :video_preparation_error }
after_destroy :destroy_activity, if: ->(notification) { notification.type == :video_preparation_error }

after_initialize :set_from_account
before_validation :set_from_account
Expand Down
2 changes: 2 additions & 0 deletions app/views/settings/preferences/show.html.haml
Expand Up @@ -33,6 +33,8 @@
= ff.input :favourite, as: :boolean, wrapper: :with_label
= ff.input :mention, as: :boolean, wrapper: :with_label
= ff.input :digest, as: :boolean, wrapper: :with_label
= ff.input :video_preparation_success, as: :boolean, wrapper: :with_label
= ff.input :video_preparation_error, as: :boolean, wrapper: :with_label

.fields-group
= f.simple_fields_for :interactions, hash_to_object(current_user.settings.interactions) do |ff|
Expand Down
3 changes: 3 additions & 0 deletions app/workers/video_preparing_worker.rb
Expand Up @@ -29,6 +29,9 @@ def perform(id)

raise
else
# 再生成の場合は前回の通知を削除する
Notification.find_by(activity_type: 'Track', activity_id: status.music.id, account: status.account)&.destroy

NotifyService.new.call(status.account, status.music)
end
end
2 changes: 2 additions & 0 deletions config/locales/simple_form.en.yml
Expand Up @@ -51,6 +51,8 @@ en:
follow_request: Send e-mail when someone requests to follow you
mention: Send e-mail when someone mentions you
reblog: Send e-mail when someone boosts your status
video_preparation_error: Send e-mail when the video generation for your track was failed
video_preparation_success: Send e-mail when the video for your track was generated
notification_firebase_cloud_messagings:
digest: Send digest mobile
favourite: Send mobile when someone favourites your status
Expand Down
2 changes: 2 additions & 0 deletions config/locales/simple_form.ja.yml
Expand Up @@ -48,6 +48,8 @@ ja:
follow_request: フォローリクエストを受けた時にメールで通知
mention: 返信された時にメールで通知
reblog: ブーストされた時にメールで通知
video_preparation_error: トラックの動画の生成に失敗した時にメールで通知
video_preparation_success: トラックの動画の生成が完了した時にメールで通知
notification_firebase_cloud_messagings:
favourite: お気に入りに登録された時にアプリで通知
follow: フォローされた時にアプリで通知
Expand Down
2 changes: 2 additions & 0 deletions config/settings.yml
Expand Up @@ -25,6 +25,8 @@ defaults: &defaults
mention: false
follow_request: true
digest: true
video_preparation_error: true
video_preparation_success: true
notification_firebase_cloud_messagings:
follow: true
reblog: true
Expand Down

0 comments on commit 5ac0d28

Please sign in to comment.