about summary refs log tree commit diff
path: root/app/javascript/flavours
diff options
context:
space:
mode:
authormultiple creatures <dev@multiple-creature.party>2019-04-28 03:03:29 -0500
committermultiple creatures <dev@multiple-creature.party>2019-05-21 03:16:22 -0500
commit1e2977256cead2a12189687c568daf7b55830561 (patch)
tree626604f36312b5ff3edfb15bb7cc249a61b57de0 /app/javascript/flavours
parent89e54748d7e227f0862c9a6a2d87cb8d73783d8a (diff)
Allow own roars to be included in lists.
Diffstat (limited to 'app/javascript/flavours')
-rw-r--r--app/javascript/flavours/glitch/actions/lists.js4
-rw-r--r--app/javascript/flavours/glitch/features/list_timeline/index.js20
2 files changed, 22 insertions, 2 deletions
diff --git a/app/javascript/flavours/glitch/actions/lists.js b/app/javascript/flavours/glitch/actions/lists.js
index c2309b8c2..30ec6442d 100644
--- a/app/javascript/flavours/glitch/actions/lists.js
+++ b/app/javascript/flavours/glitch/actions/lists.js
@@ -150,10 +150,10 @@ export const createListFail = error => ({
   error,
 });
 
-export const updateList = (id, title, shouldReset, replies_policy) => (dispatch, getState) => {
+export const updateList = (id, title, shouldReset, replies_policy, show_self) => (dispatch, getState) => {
   dispatch(updateListRequest(id));
 
-  api(getState).put(`/api/v1/lists/${id}`, { title, replies_policy }).then(({ data }) => {
+  api(getState).put(`/api/v1/lists/${id}`, { title, replies_policy, show_self }).then(({ data }) => {
     dispatch(updateListSuccess(data));
 
     if (shouldReset) {
diff --git a/app/javascript/flavours/glitch/features/list_timeline/index.js b/app/javascript/flavours/glitch/features/list_timeline/index.js
index ef829b937..c634417ce 100644
--- a/app/javascript/flavours/glitch/features/list_timeline/index.js
+++ b/app/javascript/flavours/glitch/features/list_timeline/index.js
@@ -13,10 +13,12 @@ import { fetchList, deleteList, updateList } from 'flavours/glitch/actions/lists
 import { openModal } from 'flavours/glitch/actions/modal';
 import MissingIndicator from 'flavours/glitch/components/missing_indicator';
 import LoadingIndicator from 'flavours/glitch/components/loading_indicator';
+import Toggle from 'react-toggle';
 
 const messages = defineMessages({
   deleteMessage: { id: 'confirmations.delete_list.message', defaultMessage: 'Are you sure you want to permanently delete this list?' },
   deleteConfirm: { id: 'confirmations.delete_list.confirm', defaultMessage: 'Delete' },
+  show_self:     { id: 'lists.show_self', defaultMessage: 'Include your own toots' },
   all_replies:   { id: 'lists.replies_policy.all_replies', defaultMessage: 'any followed user' },
   no_replies:    { id: 'lists.replies_policy.no_replies', defaultMessage: 'no one' },
   list_replies:  { id: 'lists.replies_policy.list_replies', defaultMessage: 'members of the list' },
@@ -114,6 +116,14 @@ export default class ListTimeline extends React.PureComponent {
     }));
   }
 
+  handleShowSelfChange = ({ target }) => {
+    const { dispatch, list } = this.props;
+    const { id } = this.props.params;
+    const replies_policy = list ? list.get('replies_policy') : undefined;
+    const show_self = list ? list.get('show_self') : false;
+    this.props.dispatch(updateList(id, undefined, false, replies_policy, !show_self));
+  }
+
   handleRepliesPolicyChange = ({ target }) => {
     const { dispatch, list } = this.props;
     const { id } = this.props.params;
@@ -126,6 +136,7 @@ export default class ListTimeline extends React.PureComponent {
     const pinned = !!columnId;
     const title  = list ? list.get('title') : id;
     const replies_policy = list ? list.get('replies_policy') : undefined;
+    const show_self = list ? list.get('show_self') : false;
 
     if (typeof list === 'undefined') {
       return (
@@ -167,6 +178,15 @@ export default class ListTimeline extends React.PureComponent {
             </button>
           </div>
 
+          <div className='column-settings__row'>
+            <div className='setting-toggle'>
+              <Toggle id={['setting', 'toggle', id, 'show_self'].join('-')} checked={show_self === true} onChange={this.handleShowSelfChange} />
+              <label htmlFor={['setting', 'toggle', id, 'show_self'].join('-')} className='setting-toggle__label'>
+                <FormattedMessage id='lists.show_self' defaultMessage='Include your own toots' />
+              </label>
+            </div>
+          </div>
+
           { replies_policy !== undefined && (
             <div>
               <div className='column-settings__row'>