Skip to content

Commit

Permalink
Add thread mode button
Browse files Browse the repository at this point in the history
  • Loading branch information
ClearlyClaire committed Feb 23, 2024
1 parent d9c4f89 commit ad2db6d
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { FederationButton } from './federation_button';
import { NavigationBar } from './navigation_bar';
import { PollForm } from "./poll_form";
import { ReplyIndicator } from './reply_indicator';
import { ThreadModeButton } from './thread_mode_button';

const allowedAroundShortCode = '><\u0085\u0020\u00a0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029\u0009\u000a\u000b\u000c\u000d';

Expand Down Expand Up @@ -304,6 +305,7 @@ class ComposeForm extends ImmutablePureComponent {
<ContentTypeButton />
<EmojiPickerDropdown onPickEmoji={this.handleEmojiPick} />
<FederationButton />
<ThreadModeButton />
<CharacterCounter max={maxChars} text={this.getFulltextForCharacterCounting()} />
</div>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { useCallback } from 'react';

import { useIntl, defineMessages } from 'react-intl';

import QuickReplyIcon from '@/material-icons/400-24px/quick_reply.svg?react';
import { changeComposeAdvancedOption } from 'flavours/glitch/actions/compose';
import { IconButton } from 'flavours/glitch/components/icon_button';
import { useAppSelector, useAppDispatch } from 'flavours/glitch/store';

const messages = defineMessages({
enable_threaded_mode: { id: 'compose.enable_threaded_mode', defaultMessage: 'Enable threaded more' },
disable_threaded_mode: { id: 'compose.disable_threaded_mode', defaultMessage: 'Disable threaded more' },
});

export const ThreadModeButton = () => {
const intl = useIntl();

const isEditing = useAppSelector((state) => state.getIn(['compose', 'id']) !== null);
const active = useAppSelector((state) => state.getIn(['compose', 'advanced_options', 'threaded_mode']));

const dispatch = useAppDispatch();

const handleClick = useCallback(() => {
dispatch(changeComposeAdvancedOption('threaded_mode', !active));
}, [active, dispatch]);

const title = intl.formatMessage(active ? messages.disable_threaded_mode : messages.enable_threaded_mode);

return (
<IconButton
disabled={isEditing}
icon=''
onClick={handleClick}
iconComponent={QuickReplyIcon}
title={title}
active={active}
size={18}
inverted
/>
);
};
2 changes: 2 additions & 0 deletions app/javascript/flavours/glitch/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
"compose.content-type.markdown_meta": "Format your posts using Markdown",
"compose.content-type.plain": "Plain text",
"compose.content-type.plain_meta": "Write with no advanced formatting",
"compose.disable_threaded_mode": "Disable threaded more",
"compose.enable_threaded_mode": "Enable threaded more",
"compose_form.sensitive.hide": "{count, plural, one {Mark media as sensitive} other {Mark media as sensitive}}",
"compose_form.sensitive.marked": "{count, plural, one {Media is marked as sensitive} other {Media is marked as sensitive}}",
"compose_form.sensitive.unmarked": "{count, plural, one {Media is not marked as sensitive} other {Media is not marked as sensitive}}",
Expand Down
11 changes: 11 additions & 0 deletions app/javascript/material-icons/400-24px/quick_reply-fill.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions app/javascript/material-icons/400-24px/quick_reply.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ad2db6d

Please sign in to comment.