Browse Source

闭社树树根帐号可配置 对所有嘟文提供树形结构

pull/4/head
欧醚 3 years ago
parent
commit
32cb3aa8d9
4 changed files with 11 additions and 8 deletions
  1. +7
    -7
      app/javascript/mastodon/features/status/index.js
  2. +1
    -0
      app/javascript/mastodon/initial_state.js
  3. +2
    -1
      app/serializers/initial_state_serializer.rb
  4. +1
    -0
      config/initializers/new_features.rb

+ 7
- 7
app/javascript/mastodon/features/status/index.js View File

@ -53,7 +53,7 @@ import { openModal } from '../../actions/modal';
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
import ImmutablePureComponent from 'react-immutable-pure-component';
import { HotKeys } from 'react-hotkeys';
import { boostModal, deleteModal } from '../../initial_state';
import { boostModal, deleteModal, treeAcct } from '../../initial_state';
import { attachFullscreenListener, detachFullscreenListener, isFullscreen } from '../ui/util/fullscreen';
import { textForScreenReader, defaultMediaVisibility } from '../../components/status';
import Icon from 'mastodon/components/icon';
@ -160,9 +160,10 @@ const makeMapStateToProps = () => {
if (status) {
ancestorsIds = getAncestorsIds(state, { id: status.get('in_reply_to_id') });
const root_status = ancestorsIds.size? getStatus(state, {id: ancestorsIds.get(0)}) : status; //error is directly visit url of non-root detailedStatus, feature!
rootAcct = root_status? root_status.getIn(['account', 'acct']) : -1;
if(rootAcct == '0') {
const root_status = ancestorsIds.size? getStatus(state, {id: ancestorsIds.get(0)}) : status;
rootAcct = root_status? root_status.getIn(['account', 'id']) : null;
if(rootAcct == treeAcct) {
deep = ancestorsIds.size;
descendantsIds = state.getIn(['contexts', 'replies', status.get('id')]);
if(descendantsIds)
descendantsIds = descendantsIds.reverse();
@ -170,8 +171,7 @@ const makeMapStateToProps = () => {
else {
descendantsIds = getDescendantsIds(state, { id: status.get('id') });
}
deep = rootAcct == '0' ? ancestorsIds.size : null;
treeData = rootAcct == '0' ? getTreeData(state, {id: status.get('id')}) : null;
treeData = getTreeData(state, {id: status.get('id')})
}
return {
@ -592,7 +592,7 @@ class Status extends ImmutablePureComponent {
showBackButton
multiColumn={multiColumn}
extraButton={(
<button className='column-header__button' title={intl.formatMessage(status.get('hidden') ? messages.revealAll : messages.hideAll)} aria-label={intl.formatMessage(status.get('hidden') ? messages.revealAll : messages.hideAll)} onClick={deep ==null ? this.handleToggleAll : this.handleShowTree} aria-pressed={status.get('hidden') ? 'false' : 'true'}><Icon id={status.get('hidden') ? 'eye-slash' : 'eye'} /></button>
<button className='column-header__button' onClick={this.handleShowTree} aria-pressed={status.get('hidden') ? 'false' : 'true'}><Icon id={this.state.showTree ? 'eye-slash' : 'eye'} /></button>
)}
/>

+ 1
- 0
app/javascript/mastodon/initial_state.js View File

@ -27,5 +27,6 @@ export const title = getMeta('title');
export const cropImages = getMeta('crop_images');
export const treeRoot = getMeta('tree_root');
export const treeAcct = getMeta('tree_acct')
export default initialState;

+ 2
- 1
app/serializers/initial_state_serializer.rb View File

@ -22,7 +22,8 @@ class InitialStateSerializer < ActiveModel::Serializer
mascot: instance_presenter.mascot&.file&.url,
profile_directory: Setting.profile_directory,
trends: Setting.trends,
tree_root: Rails.configuration.x.tree_address,
tree_root: Rails.configuration.x.tree_address,
tree_acct: Rails.configuration.x.tree_acc
}
if object.current_account

+ 1
- 0
config/initializers/new_features.rb View File

@ -3,6 +3,7 @@
Rails.application.configure do
config.x.email_default_domain = ENV.fetch('EMAIL_DEFAULT_DOMAIN') { '???.edu.cn' }
config.x.tree_address = ENV.fetch('TREE_ADDRESS') {''}
config.x.tree_acc = ENV.fetch('TREE_ACC') {'0'}
config.x.anon_tag = ENV.fetch('ANON_TAG') {'[mask]'}
config.x.anon_acc = ENV.fetch('ANON_ACC') {nil}
config.x.anon_namelist = ENV.fetch('ANON_NAME_LIST') {nil}

Loading…
Cancel
Save