Create setting for imposing a char limit (HD-19)
Signed-off-by: Marquis Kurt <software@marquiskurt.net>
This commit is contained in:
parent
0e81ae527c
commit
d8f3bf8a26
|
@ -63,6 +63,7 @@ import RefreshIcon from "@material-ui/icons/Refresh";
|
|||
import UndoIcon from "@material-ui/icons/Undo";
|
||||
import DomainDisabledIcon from "@material-ui/icons/DomainDisabled";
|
||||
import AccountSettingsIcon from "mdi-material-ui/AccountSettings";
|
||||
import AlphabeticalVariantOffIcon from "mdi-material-ui/AlphabeticalVariantOff";
|
||||
|
||||
import { Config } from "../types/Config";
|
||||
import { Account } from "../types/Account";
|
||||
|
@ -84,6 +85,7 @@ interface ISettingsState {
|
|||
brandName: string;
|
||||
federated: boolean;
|
||||
currentUser?: Account;
|
||||
imposeCharacterLimit: boolean;
|
||||
}
|
||||
|
||||
class SettingsPage extends Component<any, ISettingsState> {
|
||||
|
@ -114,7 +116,8 @@ class SettingsPage extends Component<any, ISettingsState> {
|
|||
setHyperspaceTheme(defaultTheme),
|
||||
defaultVisibility: getUserDefaultVisibility() || "public",
|
||||
brandName: "Hyperspace",
|
||||
federated: true
|
||||
federated: true,
|
||||
imposeCharacterLimit: getUserDefaultBool("imposeCharacterLimit")
|
||||
};
|
||||
|
||||
this.toggleDarkMode = this.toggleDarkMode.bind(this);
|
||||
|
@ -218,6 +221,16 @@ class SettingsPage extends Component<any, ISettingsState> {
|
|||
});
|
||||
}
|
||||
|
||||
toggleCharacterLimit() {
|
||||
this.setState({
|
||||
imposeCharacterLimit: !this.state.imposeCharacterLimit
|
||||
});
|
||||
setUserDefaultBool(
|
||||
"imposeCharacterLimit",
|
||||
!this.state.imposeCharacterLimit
|
||||
);
|
||||
}
|
||||
|
||||
toggleResetDialog() {
|
||||
this.setState({
|
||||
resetHyperspaceDialog: !this.state.resetHyperspaceDialog
|
||||
|
@ -632,6 +645,23 @@ class SettingsPage extends Component<any, ISettingsState> {
|
|||
</Button>
|
||||
</ListItemSecondaryAction>
|
||||
</ListItem>
|
||||
<ListItem>
|
||||
<ListItemAvatar>
|
||||
<AlphabeticalVariantOffIcon color="action" />
|
||||
</ListItemAvatar>
|
||||
<ListItemText
|
||||
primary="Impose character limit"
|
||||
secondary="Impose a character limit when creating posts"
|
||||
/>
|
||||
<ListItemSecondaryAction>
|
||||
<Switch
|
||||
checked={
|
||||
this.state.imposeCharacterLimit
|
||||
}
|
||||
onChange={this.toggleCharacterLimit}
|
||||
/>
|
||||
</ListItemSecondaryAction>
|
||||
</ListItem>
|
||||
</List>
|
||||
</Paper>
|
||||
<br />
|
||||
|
|
|
@ -12,6 +12,7 @@ type SettingsTemplate = {
|
|||
clearNotificationsOnRead: boolean;
|
||||
displayAllOnNotificationBadge: boolean;
|
||||
defaultVisibility: string;
|
||||
imposeCharacterLimit: boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -99,7 +100,8 @@ export function createUserDefaults() {
|
|||
enablePushNotifications: true,
|
||||
clearNotificationsOnRead: false,
|
||||
displayAllOnNotificationBadge: false,
|
||||
defaultVisibility: "public"
|
||||
defaultVisibility: "public",
|
||||
imposeCharacterLimit: true
|
||||
};
|
||||
|
||||
let settings = [
|
||||
|
@ -107,7 +109,8 @@ export function createUserDefaults() {
|
|||
"systemDecidesDarkMode",
|
||||
"clearNotificationsOnRead",
|
||||
"displayAllOnNotificationBadge",
|
||||
"defaultVisibility"
|
||||
"defaultVisibility",
|
||||
"imposeCharacterLimit"
|
||||
];
|
||||
|
||||
migrateExistingSettings();
|
||||
|
|
Loading…
Reference in New Issue