about summary refs log tree commit diff
path: root/app/javascript/themes/glitch/features/status/index.js
diff options
context:
space:
mode:
authorDavid Yip <yipdw@member.fsf.org>2017-11-28 17:34:03 -0600
committerGitHub <noreply@github.com>2017-11-28 17:34:03 -0600
commit84840e8d8c2cb4c1f7848e1148e2531edaf2c3d7 (patch)
tree5cd4327ce6e151d32d1f2d9c68487f0b47842e91 /app/javascript/themes/glitch/features/status/index.js
parent3614912be258f66155369ba9b01fa8e7336afbdd (diff)
parent6a48efe16c062b8c82975573400e44d817ab548b (diff)
Merge pull request #232 from glitch-soc/hotkeys-glitch
Implement status hotkeys + spoiler expanding
Diffstat (limited to 'app/javascript/themes/glitch/features/status/index.js')
-rw-r--r--app/javascript/themes/glitch/features/status/index.js17
1 files changed, 16 insertions, 1 deletions
diff --git a/app/javascript/themes/glitch/features/status/index.js b/app/javascript/themes/glitch/features/status/index.js
index 57af94a9a..8561bd4de 100644
--- a/app/javascript/themes/glitch/features/status/index.js
+++ b/app/javascript/themes/glitch/features/status/index.js
@@ -71,6 +71,7 @@ export default class Status extends ImmutablePureComponent {
 
   state = {
     fullscreen: false,
+    isExpanded: null,
   };
 
   componentWillMount () {
@@ -88,6 +89,12 @@ export default class Status extends ImmutablePureComponent {
     }
   }
 
+  handleExpandedToggle = () => {
+    if (this.props.status.get('spoiler_text')) {
+      this.setExpansion(this.state.isExpanded ? null : true);
+    }
+  };
+
   handleFavouriteClick = (status) => {
     if (status.get('favourited')) {
       this.props.dispatch(unfavourite(status));
@@ -241,6 +248,10 @@ export default class Status extends ImmutablePureComponent {
     ));
   }
 
+  setExpansion = value => {
+    this.setState({ isExpanded: value ? true : null });
+  }
+
   setRef = c => {
     this.node = c;
   }
@@ -272,8 +283,9 @@ export default class Status extends ImmutablePureComponent {
 
   render () {
     let ancestors, descendants;
+    const { setExpansion } = this;
     const { status, settings, ancestorsIds, descendantsIds } = this.props;
-    const { fullscreen } = this.state;
+    const { fullscreen, isExpanded } = this.state;
 
     if (status === null) {
       return (
@@ -300,6 +312,7 @@ export default class Status extends ImmutablePureComponent {
       boost: this.handleHotkeyBoost,
       mention: this.handleHotkeyMention,
       openProfile: this.handleHotkeyOpenProfile,
+      toggleSpoiler: this.handleExpandedToggle,
     };
 
     return (
@@ -317,6 +330,8 @@ export default class Status extends ImmutablePureComponent {
                   settings={settings}
                   onOpenVideo={this.handleOpenVideo}
                   onOpenMedia={this.handleOpenMedia}
+                  expanded={isExpanded}
+                  setExpansion={setExpansion}
                 />
 
                 <ActionBar