mirror of
https://github.com/mastodon/mastodon.git
synced 2025-12-13 21:52:42 +00:00
Fix subscribed languages / 1
This commit is contained in:
parent
d50110a17a
commit
f22e2e3d7c
|
|
@ -26,6 +26,7 @@ export interface BaseApiAccountJSON {
|
||||||
fields: ApiAccountFieldJSON[];
|
fields: ApiAccountFieldJSON[];
|
||||||
followers_count: number;
|
followers_count: number;
|
||||||
following_count: number;
|
following_count: number;
|
||||||
|
used_languages: string[];
|
||||||
group: boolean;
|
group: boolean;
|
||||||
header: string;
|
header: string;
|
||||||
header_static: string;
|
header_static: string;
|
||||||
|
|
|
||||||
|
|
@ -19,11 +19,32 @@ const messages = defineMessages({
|
||||||
close: { id: 'lightbox.close', defaultMessage: 'Close' },
|
close: { id: 'lightbox.close', defaultMessage: 'Close' },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
const getAccountLanguages = createSelector([
|
const getAccountLanguages = createSelector([
|
||||||
(state, accountId) => state.getIn(['timelines', `account:${accountId}`, 'items'], ImmutableList()),
|
(state, accountId) => state.getIn(['timelines', `account:${accountId}`, 'items'], ImmutableList()),
|
||||||
state => state.get('statuses'),
|
state => state.get('statuses'),
|
||||||
], (statusIds, statuses) =>
|
], (statusIds, statuses) =>
|
||||||
ImmutableSet(statusIds.map(statusId => statuses.get(statusId)).filter(status => !status.get('reblog')).map(status => status.get('language'))));
|
ImmutableSet(statusIds.map(statusId => statuses.get(statusId)).filter(status => !status.get('reblog')).map(status => status.get('language'))));
|
||||||
|
*/
|
||||||
|
|
||||||
|
const getAccountLanguages = createSelector([
|
||||||
|
(state, accountId) => state.getIn(['accounts', accountId, 'used_languages']),
|
||||||
|
], (used_languages) => {
|
||||||
|
console.log('used_languages', used_languages);
|
||||||
|
return ImmutableSet(used_languages);
|
||||||
|
});
|
||||||
|
|
||||||
|
//dispatch(fetchAccount(accountId));
|
||||||
|
/*const getAccountLanguages = (state, accountId) => {
|
||||||
|
const account =
|
||||||
|
console.log('account', account)
|
||||||
|
const list = (account.used_languages ? account.used_languages : []);
|
||||||
|
list.push('de');
|
||||||
|
return ImmutableSet(list);
|
||||||
|
};*/
|
||||||
|
/*const account = useAppSelector((state) =>
|
||||||
|
accountId ? state.accounts.get(accountId) : undefined,
|
||||||
|
);*/
|
||||||
|
|
||||||
const mapStateToProps = (state, { accountId }) => ({
|
const mapStateToProps = (state, { accountId }) => ({
|
||||||
acct: state.getIn(['accounts', accountId, 'acct']),
|
acct: state.getIn(['accounts', accountId, 'acct']),
|
||||||
|
|
@ -56,6 +77,7 @@ class SubscribedLanguagesModal extends ImmutablePureComponent {
|
||||||
languages: preloadedLanguages,
|
languages: preloadedLanguages,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
state = {
|
state = {
|
||||||
selectedLanguages: this.props.selectedLanguages,
|
selectedLanguages: this.props.selectedLanguages,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -97,6 +97,7 @@ export const accountDefaultValues: AccountShape = {
|
||||||
// This comes from `ApiMutedAccountJSON`, but we should eventually
|
// This comes from `ApiMutedAccountJSON`, but we should eventually
|
||||||
// store that in a different object.
|
// store that in a different object.
|
||||||
mute_expires_at: null,
|
mute_expires_at: null,
|
||||||
|
used_languages: []
|
||||||
};
|
};
|
||||||
|
|
||||||
const AccountFactory = ImmutableRecord<AccountShape>(accountDefaultValues);
|
const AccountFactory = ImmutableRecord<AccountShape>(accountDefaultValues);
|
||||||
|
|
|
||||||
|
|
@ -30,10 +30,18 @@ class AccountStat < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def followers_count
|
def followers_count
|
||||||
|
puts 'call followers_count'
|
||||||
|
puts caller
|
||||||
[attributes['followers_count'], 0].max
|
[attributes['followers_count'], 0].max
|
||||||
end
|
end
|
||||||
|
|
||||||
def statuses_count
|
def statuses_count
|
||||||
[attributes['statuses_count'], 0].max
|
[attributes['statuses_count'], 0].max
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def used_languages
|
||||||
|
list = Status.select(:language).reorder(:language).where(account_id: attributes['account_id']).distinct(:language).pluck(:language)
|
||||||
|
#list.push('de')
|
||||||
|
list
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ module Account::Counters
|
||||||
:followers_count,
|
:followers_count,
|
||||||
:followers_count=,
|
:followers_count=,
|
||||||
:last_status_at,
|
:last_status_at,
|
||||||
|
:used_languages,
|
||||||
to: :account_stat
|
to: :account_stat
|
||||||
|
|
||||||
# @param [Symbol] key
|
# @param [Symbol] key
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ class REST::AccountSerializer < ActiveModel::Serializer
|
||||||
# Please update `app/javascript/mastodon/api_types/accounts.ts` when making changes to the attributes
|
# Please update `app/javascript/mastodon/api_types/accounts.ts` when making changes to the attributes
|
||||||
|
|
||||||
attributes :id, :username, :acct, :display_name, :locked, :bot, :discoverable, :indexable, :group, :created_at,
|
attributes :id, :username, :acct, :display_name, :locked, :bot, :discoverable, :indexable, :group, :created_at,
|
||||||
:note, :url, :uri, :avatar, :avatar_static, :header, :header_static,
|
:note, :url, :uri, :avatar, :avatar_static, :header, :header_static, :used_languages,
|
||||||
:followers_count, :following_count, :statuses_count, :last_status_at, :hide_collections
|
:followers_count, :following_count, :statuses_count, :last_status_at, :hide_collections
|
||||||
|
|
||||||
has_one :moved_to_account, key: :moved, serializer: REST::AccountSerializer, if: :moved_and_not_nested?
|
has_one :moved_to_account, key: :moved, serializer: REST::AccountSerializer, if: :moved_and_not_nested?
|
||||||
|
|
@ -88,6 +88,10 @@ class REST::AccountSerializer < ActiveModel::Serializer
|
||||||
full_asset_url(object.unavailable? ? object.header.default_url : object.header_static_url)
|
full_asset_url(object.unavailable? ? object.header.default_url : object.header_static_url)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_benoit
|
||||||
|
'he ouais ' + Time.now.to_s
|
||||||
|
end
|
||||||
|
|
||||||
def created_at
|
def created_at
|
||||||
object.created_at.midnight.as_json
|
object.created_at.midnight.as_json
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user