1
0
mirror of https://github.com/hyperspacedev/hyperspace synced 2025-02-07 04:43:20 +01:00

Trim notification text in Notifications page

This commit is contained in:
Marquis Kurt 2019-04-20 15:09:15 -04:00
parent a92693bb84
commit 6cde355870

View File

@ -80,7 +80,8 @@ class NotificationsPage extends Component<any, INotificationsPageState> {
const div = document.createElement('div');
div.innerHTML = text;
let innerContent = div.textContent || div.innerText || "";
innerContent = innerContent.slice(0, 85) + "..."
if (innerContent.length > 65)
innerContent = innerContent.slice(0, 65) + "...";
return innerContent;
}
@ -115,6 +116,7 @@ class NotificationsPage extends Component<any, INotificationsPageState> {
}
createNotification(notif: Notification) {
const { classes } = this.props;
let primary = "";
let secondary = "";
switch (notif.type) {
@ -149,7 +151,16 @@ class NotificationsPage extends Component<any, INotificationsPageState> {
<PersonIcon/>
</Avatar>
</ListItemAvatar>
<ListItemText primary={primary} secondary={secondary}/>
<ListItemText primary={primary} secondary={
<span>
<Typography color="textSecondary" className={classes.mobileOnly}>
{secondary.slice(0, 35) + "..."}
</Typography>
<Typography color="textSecondary" className={classes.desktopOnly}>
{secondary}
</Typography>
</span>
}/>
<ListItemSecondaryAction>
{
notif.type === "follow"?