[Glitch] Remove timeline preview link from nav panel when not signed-in

Port e82467ca41 to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
pull/1876/head
Yamagishi Kazutoshi 2022-10-09 10:49:51 +09:00 committed by Claire
parent 07df273f37
commit 8491a3532d
3 changed files with 75 additions and 17 deletions

View File

@ -1,12 +1,12 @@
import React from 'react';
import PropTypes from 'prop-types';
import { domain } from 'flavours/glitch/initial_state';
import { fetchServer } from 'flavours/glitch/actions/server';
import React from 'react';
import { FormattedMessage, defineMessages, injectIntl } from 'react-intl';
import { connect } from 'react-redux';
import Account from 'flavours/glitch/containers/account_container';
import { fetchServer } from 'flavours/glitch/actions/server';
import ShortNumber from 'flavours/glitch/components/short_number';
import Skeleton from 'flavours/glitch/components/skeleton';
import { FormattedMessage, injectIntl, defineMessages } from 'react-intl';
import Account from 'flavours/glitch/containers/account_container';
import { domain } from 'flavours/glitch/initial_state';
const messages = defineMessages({
aboutActiveUsers: { id: 'server_banner.about_active_users', defaultMessage: 'People using this server during the last 30 days (Monthly Active Users)' },

View File

@ -1,15 +1,15 @@
import React from 'react';
import PropTypes from 'prop-types';
import { NavLink, Link } from 'react-router-dom';
import React from 'react';
import { FormattedMessage } from 'react-intl';
import { Link, NavLink } from 'react-router-dom';
import Icon from 'flavours/glitch/components/icon';
import { showTrends } from 'flavours/glitch/initial_state';
import { preferencesLink, relationshipsLink } from 'flavours/glitch/utils/backend_links';
import NotificationsCounterIcon from './notifications_counter_icon';
import TrendsContainer from 'flavours/glitch/features/getting_started/containers/trends_container';
import { showTrends, timelinePreview } from 'flavours/glitch/initial_state';
import FollowRequestsNavLink from './follow_requests_nav_link';
import ListPanel from './list_panel';
import TrendsContainer from 'flavours/glitch/features/getting_started/containers/trends_container';
import NotificationsCounterIcon from './notifications_counter_icon';
import SignInBanner from './sign_in_banner';
import { preferencesLink, relationshipsLink } from 'flavours/glitch/utils/backend_links';
export default class NavigationPanel extends React.Component {
@ -36,10 +36,13 @@ export default class NavigationPanel extends React.Component {
</React.Fragment>
)}
{ showTrends && <NavLink className='column-link column-link--transparent' to='/explore' data-preview-title-id='explore.title' data-preview-icon='hashtag'><Icon className='column-link__icon' id='hashtag' fixedWidth /><FormattedMessage id='explore.title' defaultMessage='Explore' /></NavLink> }
<NavLink className='column-link column-link--transparent' to='/explore' data-preview-title-id='explore.title' data-preview-icon='hashtag'><Icon className='column-link__icon' id='hashtag' fixedWidth /><FormattedMessage id='explore.title' defaultMessage='Explore' /></NavLink>
{signedIn || timelinePreview && (
<>
<NavLink className='column-link column-link--transparent' to='/public/local' data-preview-title-id='column.community' data-preview-icon='users' ><Icon className='column-link__icon' id='users' fixedWidth /><FormattedMessage id='tabs_bar.local_timeline' defaultMessage='Local' /></NavLink>
<NavLink className='column-link column-link--transparent' exact to='/public' data-preview-title-id='column.public' data-preview-icon='globe' ><Icon className='column-link__icon' id='globe' fixedWidth /><FormattedMessage id='tabs_bar.federated_timeline' defaultMessage='Federated' /></NavLink>
</>
)}
{!signedIn && (
<div className='navigation-panel__sign-in-banner'>

View File

@ -1,4 +1,52 @@
// @ts-check
/**
* @typedef {[code: string, name: string, localName: string]} InitialStateLanguage
*/
/**
* @typedef InitialStateMeta
* @property {string} access_token
* @property {boolean=} advanced_layout
* @property {boolean} auto_play_gif
* @property {boolean} activity_api_enabled
* @property {string} admin
* @property {boolean=} boost_modal
* @property {boolean} crop_images
* @property {boolean=} delete_modal
* @property {boolean=} disable_swiping
* @property {boolean} display_media
* @property {string} domain
* @property {boolean=} expand_spoilers
* @property {boolean} limited_federation_mode
* @property {string} locale
* @property {string | null} mascot
* @property {string=} me
* @property {boolean} profile_directory
* @property {boolean} registrations_open
* @property {boolean} reduce_motion
* @property {string} repository
* @property {boolean} search_enabled
* @property {string} source_url
* @property {string} streaming_api_base_url
* @property {boolean} timeline_preview
* @property {string} title
* @property {boolean} trends
* @property {boolean} unfollow_modal
* @property {boolean} use_blurhash
* @property {boolean=} use_pending_items
* @property {string} version
* @property {object} local_settings
*/
/**
* @typedef InitialState
* @property {InitialStateLanguage[]} languages
* @property {InitialStateMeta} meta
*/
const element = document.getElementById('initial-state');
/** @type {InitialState | undefined} */
const initialState = element && JSON.parse(element.textContent);
// Glitch-soc-specific “local settings”
@ -8,7 +56,12 @@ try {
initialState.local_settings = {};
}
const getMeta = (prop) => initialState && initialState.meta && initialState.meta[prop];
/**
* @template {keyof InitialStateMeta} K
* @param {K} prop
* @returns {InitialStateMeta[K] | undefined}
*/
const getMeta = (prop) => initialState?.meta && initialState.meta[prop];
export const domain = getMeta('domain');
export const reduceMotion = getMeta('reduce_motion');
@ -34,7 +87,9 @@ export const usePendingItems = getMeta('use_pending_items');
export const showTrends = getMeta('trends');
export const title = getMeta('title');
export const disableSwiping = getMeta('disable_swiping');
export const languages = initialState && initialState.languages;
export const timelinePreview = getMeta('timeline_preview');
export const activityApiEnabled = getMeta('activity_api_enabled');
export const languages = initialState?.languages;
// Glitch-soc-specific settings
export const favouriteModal = getMeta('favourite_modal');