diff --git a/src/pages/Compose.tsx b/src/pages/Compose.tsx index 421f229..ed81f03 100644 --- a/src/pages/Compose.tsx +++ b/src/pages/Compose.tsx @@ -20,7 +20,7 @@ import ComposeMediaAttachment from '../components/ComposeMediaAttachment'; import EmojiPicker from '../components/EmojiPicker'; import { DateTimePicker, MuiPickersUtilsProvider } from 'material-ui-pickers'; import MomentUtils from '@date-io/moment'; -import { getUserDefaultVisibility } from '../utilities/settings'; +import { getUserDefaultVisibility, getConfig } from '../utilities/settings'; interface IComposerState { account: UAccount; @@ -36,6 +36,7 @@ interface IComposerState { poll?: PollWizard; pollExpiresDate?: any; showEmojis: boolean; + federated: boolean; } class Composer extends Component { @@ -54,20 +55,26 @@ class Composer extends Component { visibilityMenu: false, text: '', remainingChars: 500, - showEmojis: false + showEmojis: false, + federated: true } } componentDidMount() { let state = this.getComposerParams(this.props); let text = state.acct? `@${state.acct}: `: ''; - this.setState({ - reply: state.reply, - acct: state.acct, - visibility: state.visibility, - text, - remainingChars: 500 - text.length + getConfig().then((config: any) => { + this.setState({ + federated: config.federated === "true", + reply: state.reply, + acct: state.acct, + visibility: state.visibility, + text, + remainingChars: 500 - text.length + }); }) + + } componentWillReceiveProps(props: any) { @@ -500,7 +507,7 @@ class Composer extends Component { this.changeVisibility('direct')}>Direct (direct message) this.changeVisibility('private')}>Private (followers only) this.changeVisibility('unlisted')}>Unlisted - this.changeVisibility('public')}>Public + {this.state.federated? this.changeVisibility('public')}>Public: null} diff --git a/src/pages/Notifications.tsx b/src/pages/Notifications.tsx index 24b6a18..2a3abdb 100644 --- a/src/pages/Notifications.tsx +++ b/src/pages/Notifications.tsx @@ -252,7 +252,7 @@ class NotificationsPage extends Component { : -
+
All clear! It looks like you have no notifications. Why not get the conversation going with a new post?
: diff --git a/src/pages/PageLayout.styles.tsx b/src/pages/PageLayout.styles.tsx index 43d2731..155005d 100644 --- a/src/pages/PageLayout.styles.tsx +++ b/src/pages/PageLayout.styles.tsx @@ -52,6 +52,10 @@ export const styles = (theme: Theme) => createStyles({ marginLeft: 250, }, }, + pageLayoutEmptyTextConstraints: { + paddingLeft: theme.spacing.unit * 2, + paddingRight: theme.spacing.unit * 2 + }, pageHeroBackground: { position: 'relative', height: 'intrinsic', @@ -174,5 +178,5 @@ export const styles = (theme: Theme) => createStyles({ '& a': { color: theme.palette.primary.light } - } + }, }); \ No newline at end of file diff --git a/src/pages/Recommendations.tsx b/src/pages/Recommendations.tsx index 9eb8dc8..b43f789 100644 --- a/src/pages/Recommendations.tsx +++ b/src/pages/Recommendations.tsx @@ -201,7 +201,7 @@ class RecommendationsPage extends Component 0? this.showFollowRequests(): -
+
You don't have any follow requests.
@@ -210,7 +210,7 @@ class RecommendationsPage extends Component { this.state.followSuggestions && this.state.followSuggestions.length > 0? this.showFollowSuggestions(): -
+
We don't have any suggestions for you. Why not interact with the fediverse a bit by creating a new post?
diff --git a/src/pages/Search.tsx b/src/pages/Search.tsx index d6708db..5f16932 100644 --- a/src/pages/Search.tsx +++ b/src/pages/Search.tsx @@ -164,11 +164,12 @@ class SearchPage extends Component { return (
Accounts - - + { - this.state.results? - this.state.results.accounts.map((acct: Account) => { + this.state.results && this.state.results.accounts.length > 0? + + + { this.state.results.accounts.map((acct: Account) => { return ( @@ -189,16 +190,19 @@ class SearchPage extends Component { ); - }): null + })} + + : No results found } - - + +
) } showAllPostsFromQuery() { + const {classes} = this.props; return (
Posts @@ -207,13 +211,14 @@ class SearchPage extends Component { this.state.results.statuses.length > 0? this.state.results.statuses.map((post: Status) => { return - }): No results found.: null + }): No results found.: null }
); } showAllPostsWithTag() { + const {classes} = this.props; return (
Tagged posts @@ -222,7 +227,7 @@ class SearchPage extends Component { this.state.tagResults.length > 0? this.state.tagResults.map((post: Status) => { return - }): No results found.: null + }): No results found.: null }
); diff --git a/src/pages/Settings.tsx b/src/pages/Settings.tsx index 76b7720..5fe8e5c 100644 --- a/src/pages/Settings.tsx +++ b/src/pages/Settings.tsx @@ -24,7 +24,7 @@ import { } from '@material-ui/core'; import OpenInNewIcon from '@material-ui/icons/OpenInNew'; import {styles} from './PageLayout.styles'; -import {setUserDefaultBool, getUserDefaultBool, getUserDefaultTheme, setUserDefaultTheme, getUserDefaultVisibility, setUserDefaultVisibility} from '../utilities/settings'; +import {setUserDefaultBool, getUserDefaultBool, getUserDefaultTheme, setUserDefaultTheme, getUserDefaultVisibility, setUserDefaultVisibility, getConfig} from '../utilities/settings'; import {canSendNotifications, browserSupportsNotificationRequests} from '../utilities/notifications'; import {themes, defaultTheme} from '../types/HyperspaceTheme'; import ThemePreview from '../components/ThemePreview'; @@ -43,6 +43,7 @@ interface ISettingsState { resetSettingsDialog: boolean; previewTheme: Theme; defaultVisibility: Visibility; + federated: boolean; } class SettingsPage extends Component { @@ -61,7 +62,8 @@ class SettingsPage extends Component { resetHyperspaceDialog: false, resetSettingsDialog: false, previewTheme: setHyperspaceTheme(getUserDefaultTheme()) || setHyperspaceTheme(defaultTheme), - defaultVisibility: getUserDefaultVisibility() || "public" + defaultVisibility: getUserDefaultVisibility() || "public", + federated: true } this.toggleDarkMode = this.toggleDarkMode.bind(this); @@ -75,6 +77,16 @@ class SettingsPage extends Component { this.setVisibility = this.setVisibility.bind(this); } + componentDidMount() { + this.getFederatedStatus(); + } + + getFederatedStatus() { + getConfig().then((config: any) => { + this.setState({ federated: config.federated === "true" }); + }) + } + toggleDarkMode() { this.setState({ darkModeEnabled: !this.state.darkModeEnabled }); setUserDefaultBool('darkModeEnabled', !this.state.darkModeEnabled); @@ -208,7 +220,7 @@ class SettingsPage extends Component { value={this.state.defaultVisibility} onChange={(e, value) => this.changeVisibility(value as Visibility)} > - } label={"Public"} /> + } label={`Public ${this.state.federated? "": "(disabled by provider)"}`} disabled={!this.state.federated}/> } label={"Unlisted"} /> } label={"Private (followers only)"} /> } label={"Direct"} /> diff --git a/src/pages/Welcome.tsx b/src/pages/Welcome.tsx index 40b4769..675c4a5 100644 --- a/src/pages/Welcome.tsx +++ b/src/pages/Welcome.tsx @@ -34,6 +34,7 @@ interface IWelcomeState { openAuthDialog: boolean; authCode: string; emergencyMode: boolean; + version: string; } class WelcomePage extends Component { @@ -53,7 +54,8 @@ class WelcomePage extends Component { defaultRedirectAddress: '', openAuthDialog: false, authCode: '', - emergencyMode: false + emergencyMode: false, + version: '' } getConfig().then((result: any) => { @@ -68,7 +70,8 @@ class WelcomePage extends Component { federates: result.federated? result.federated === "true": true, license: result.license.url, repo: result.repository, - defaultRedirectAddress: result.location != "dynamic"? result.location: `https://${window.location.host}` + defaultRedirectAddress: result.location != "dynamic"? result.location: `https://${window.location.host}`, + version: result.version }); }).catch(() => { console.error('config.json is missing. If you want to customize Hyperspace, please include config.json'); @@ -134,7 +137,7 @@ class WelcomePage extends Component { } getLoginUser(user: string) { - if (user.includes("@")) { + if (this.state.federates || user.includes("@")) { let newUser = user; this.setState({ user: newUser }) return "https://" + newUser.split("@")[1]; @@ -222,17 +225,28 @@ class WelcomePage extends Component { return true; } else { if (this.state.user.includes("@")) { - let baseUrl = this.state.user.split("@")[1]; - axios.get("https://" + baseUrl + "/api/v1/timelines/public").catch((err: Error) => { - let userInputError = true; - let userInputErrorMessage = "Instance name is invalid."; + if (this.state.federates && (this.state.federates === true)) { + let baseUrl = this.state.user.split("@")[1]; + axios.get("https://" + baseUrl + "/api/v1/timelines/public").catch((err: Error) => { + let userInputError = true; + let userInputErrorMessage = "Instance name is invalid."; + this.setState({ userInputError, userInputErrorMessage }); + return true; + }); + } else if (this.state.user.includes(this.state.registerBase? this.state.registerBase: "mastodon.social")) { + this.setState({ userInputError, userInputErrorMessage }); + return false; + } else { + userInputError = true; + userInputErrorMessage = "You cannot sign in with this username."; this.setState({ userInputError, userInputErrorMessage }); return true; - }) + } } else { this.setState({ userInputError, userInputErrorMessage }); return false; } + this.setState({ userInputError, userInputErrorMessage }); return false; } @@ -276,9 +290,9 @@ class WelcomePage extends Component {
this.updateUserInfo(event.target.value)} error={this.state.userInputError} onBlur={() => this.checkForErrors()} @@ -288,13 +302,13 @@ class WelcomePage extends Component { }
{ - this.state.registerBase? If you are from {this.state.registerBase? this.state.registerBase: "noinstance"}, sign in with your username.: null + this.state.registerBase && this.state.federates? Not from {this.state.registerBase? this.state.registerBase: "noinstance"}? Sign in with your full username.: null }
{ this.state.foundSavedLogin? - Signing in from a previous session? this.resumeLogin()}>Continue login. + Signing in from a previous session? this.resumeLogin()}>Continue login. : null } @@ -302,7 +316,6 @@ class WelcomePage extends Component {