[Glitch] Refactor CW handling in an action
Port 9cb9427133 to glitch-soc
Signed-off-by: Claire <claire.github-309c@sitedethib.com>
			
			
This commit is contained in:
		
							parent
							
								
									f13a231b39
								
							
						
					
					
						commit
						643b1ef3e9
					
				| 
						 | 
					@ -309,6 +309,21 @@ export function revealStatus(ids) {
 | 
				
			||||||
  };
 | 
					  };
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export function toggleStatusSpoilers(statusId) {
 | 
				
			||||||
 | 
					  return (dispatch, getState) => {
 | 
				
			||||||
 | 
					    const status = getState().statuses.get(statusId);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (!status)
 | 
				
			||||||
 | 
					      return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (status.get('hidden')) {
 | 
				
			||||||
 | 
					      dispatch(revealStatus(statusId));
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					      dispatch(hideStatus(statusId));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  };
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export function toggleStatusCollapse(id, isCollapsed) {
 | 
					export function toggleStatusCollapse(id, isCollapsed) {
 | 
				
			||||||
  return {
 | 
					  return {
 | 
				
			||||||
    type: STATUS_COLLAPSE,
 | 
					    type: STATUS_COLLAPSE,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -28,8 +28,7 @@ import {
 | 
				
			||||||
  muteStatus,
 | 
					  muteStatus,
 | 
				
			||||||
  unmuteStatus,
 | 
					  unmuteStatus,
 | 
				
			||||||
  deleteStatus,
 | 
					  deleteStatus,
 | 
				
			||||||
  hideStatus,
 | 
					  toggleStatusSpoilers,
 | 
				
			||||||
  revealStatus,
 | 
					 | 
				
			||||||
  editStatus,
 | 
					  editStatus,
 | 
				
			||||||
  translateStatus,
 | 
					  translateStatus,
 | 
				
			||||||
  undoStatusTranslation,
 | 
					  undoStatusTranslation,
 | 
				
			||||||
| 
						 | 
					@ -234,11 +233,7 @@ const mapDispatchToProps = (dispatch, { intl, contextType }) => ({
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  onToggleHidden (status) {
 | 
					  onToggleHidden (status) {
 | 
				
			||||||
    if (status.get('hidden')) {
 | 
					    dispatch(toggleStatusSpoilers(status.get('id')));
 | 
				
			||||||
      dispatch(revealStatus(status.get('id')));
 | 
					 | 
				
			||||||
    } else {
 | 
					 | 
				
			||||||
      dispatch(hideStatus(status.get('id')));
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  deployPictureInPicture (status, type, mediaProps) {
 | 
					  deployPictureInPicture (status, type, mediaProps) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -18,7 +18,7 @@ import ReplyIcon from '@/material-icons/400-24px/reply.svg?react';
 | 
				
			||||||
import { replyCompose } from 'flavours/glitch/actions/compose';
 | 
					import { replyCompose } from 'flavours/glitch/actions/compose';
 | 
				
			||||||
import { markConversationRead, deleteConversation } from 'flavours/glitch/actions/conversations';
 | 
					import { markConversationRead, deleteConversation } from 'flavours/glitch/actions/conversations';
 | 
				
			||||||
import { openModal } from 'flavours/glitch/actions/modal';
 | 
					import { openModal } from 'flavours/glitch/actions/modal';
 | 
				
			||||||
import { muteStatus, unmuteStatus, revealStatus, hideStatus } from 'flavours/glitch/actions/statuses';
 | 
					import { muteStatus, unmuteStatus, toggleStatusSpoilers } from 'flavours/glitch/actions/statuses';
 | 
				
			||||||
import AttachmentList from 'flavours/glitch/components/attachment_list';
 | 
					import AttachmentList from 'flavours/glitch/components/attachment_list';
 | 
				
			||||||
import AvatarComposite from 'flavours/glitch/components/avatar_composite';
 | 
					import AvatarComposite from 'flavours/glitch/components/avatar_composite';
 | 
				
			||||||
import { IconButton } from 'flavours/glitch/components/icon_button';
 | 
					import { IconButton } from 'flavours/glitch/components/icon_button';
 | 
				
			||||||
| 
						 | 
					@ -156,11 +156,7 @@ export const Conversation = ({ conversation, scrollKey, onMoveUp, onMoveDown })
 | 
				
			||||||
  }, [dispatch, lastStatus]);
 | 
					  }, [dispatch, lastStatus]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const handleShowMore = useCallback(() => {
 | 
					  const handleShowMore = useCallback(() => {
 | 
				
			||||||
    if (lastStatus.get('hidden')) {
 | 
					    dispatch(toggleStatusSpoilers(lastStatus.get('id')));
 | 
				
			||||||
      dispatch(revealStatus(lastStatus.get('id')));
 | 
					 | 
				
			||||||
    } else {
 | 
					 | 
				
			||||||
      dispatch(hideStatus(lastStatus.get('id')));
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (lastStatus.get('spoiler_text')) {
 | 
					    if (lastStatus.get('spoiler_text')) {
 | 
				
			||||||
      setExpanded(!expanded);
 | 
					      setExpanded(!expanded);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue