Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge and port upstream's composer change #2644

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
6936e5a
Change design of compose form in web UI (#28119)
Gargron Jan 25, 2024
10a0d76
Merge commit '6936e5aa693ccc4aabd26ef18a65fbb8132f6f74' into glitch-s…
ClearlyClaire Feb 22, 2024
7586d43
Switch glitch-soc to upstream's old composer
ClearlyClaire Feb 22, 2024
9c10aaa
[Glitch] Change design of compose form in web UI
Gargron Jan 25, 2024
5fd5075
Restore glitch-soc's support of custom poll limits
ClearlyClaire Feb 22, 2024
380f4fc
Reimplement sensitive checkbox
ClearlyClaire Feb 22, 2024
056f9bf
Add back “spoilers always on” feature
ClearlyClaire Feb 23, 2024
179437e
Restore access to glitch-soc app settings
ClearlyClaire Feb 22, 2024
61559a4
Restore glitch-soc's permalink behavior for reply indicator
ClearlyClaire Feb 22, 2024
118bb5b
Add secondary post button back
ClearlyClaire Feb 22, 2024
47deb68
Add Content-Type dropdown back
ClearlyClaire Feb 22, 2024
0e77c45
Add local-only option back as a federation setting dropdown
ClearlyClaire Feb 23, 2024
3564a15
Refactor composer dropdowns
ClearlyClaire Feb 23, 2024
84d05ca
Reimplement glitchy elephant friend
ClearlyClaire Feb 23, 2024
23dc650
Restore preselect on reply option
ClearlyClaire Feb 23, 2024
e62cd93
Fix composer offering to edit federation settings for an existing post
ClearlyClaire Feb 23, 2024
e333453
Use Warning icon for CWs in app settings
ClearlyClaire Feb 23, 2024
9ab030b
Add thread mode button
ClearlyClaire Feb 23, 2024
6eede9d
Add notification badge feature back
ClearlyClaire Feb 23, 2024
1382861
Fix emoji being inserted in incorrect places
ClearlyClaire Feb 23, 2024
6901930
Add back confirmation modal for missing media description
ClearlyClaire Feb 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ module.exports = defineConfig({
// },
// ],
'jsx-a11y/no-noninteractive-tabindex': 'off',
'jsx-a11y/no-onchange': 'warn',
'jsx-a11y/no-onchange': 'off',
// recommended is full 'error'
'jsx-a11y/no-static-element-interactions': [
'warn',
Expand Down
58 changes: 29 additions & 29 deletions app/javascript/flavours/glitch/actions/compose.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ let fetchComposeSuggestionsAccountsController;
let fetchComposeSuggestionsTagsController;

export const COMPOSE_CHANGE = 'COMPOSE_CHANGE';
export const COMPOSE_CYCLE_ELEFRIEND = 'COMPOSE_CYCLE_ELEFRIEND';
export const COMPOSE_SUBMIT_REQUEST = 'COMPOSE_SUBMIT_REQUEST';
export const COMPOSE_SUBMIT_SUCCESS = 'COMPOSE_SUBMIT_SUCCESS';
export const COMPOSE_SUBMIT_FAIL = 'COMPOSE_SUBMIT_FAIL';
Expand Down Expand Up @@ -59,7 +58,7 @@ export const COMPOSE_SENSITIVITY_CHANGE = 'COMPOSE_SENSITIVITY_CHANGE';
export const COMPOSE_SPOILERNESS_CHANGE = 'COMPOSE_SPOILERNESS_CHANGE';
export const COMPOSE_SPOILER_TEXT_CHANGE = 'COMPOSE_SPOILER_TEXT_CHANGE';
export const COMPOSE_VISIBILITY_CHANGE = 'COMPOSE_VISIBILITY_CHANGE';
export const COMPOSE_LISTABILITY_CHANGE = 'COMPOSE_LISTABILITY_CHANGE';
export const COMPOSE_COMPOSING_CHANGE = 'COMPOSE_COMPOSING_CHANGE';
export const COMPOSE_CONTENT_TYPE_CHANGE = 'COMPOSE_CONTENT_TYPE_CHANGE';
export const COMPOSE_LANGUAGE_CHANGE = 'COMPOSE_LANGUAGE_CHANGE';

Expand Down Expand Up @@ -117,12 +116,6 @@ export function changeCompose(text) {
};
}

export function cycleElefriendCompose() {
return {
type: COMPOSE_CYCLE_ELEFRIEND,
};
}

export function replyCompose(status, routerHistory) {
return (dispatch, getState) => {
const prependCWRe = getState().getIn(['local_settings', 'prepend_cw_re']);
Expand All @@ -148,13 +141,13 @@ export function resetCompose() {
};
}

export const focusCompose = (routerHistory, defaultText) => dispatch => {
export const focusCompose = (routerHistory, defaultText) => (dispatch, getState) => {
dispatch({
type: COMPOSE_FOCUS,
defaultText,
});

ensureComposeIsVisible(routerHistory);
ensureComposeIsVisible(getState, routerHistory);
};

export function mentionCompose(account, routerHistory) {
Expand All @@ -179,7 +172,7 @@ export function directCompose(account, routerHistory) {
};
}

export function submitCompose(routerHistory) {
export function submitCompose(routerHistory, overridePrivacy = null) {
return function (dispatch, getState) {
let status = getState().getIn(['compose', 'text'], '');
const media = getState().getIn(['compose', 'media_attachments']);
Expand Down Expand Up @@ -228,7 +221,7 @@ export function submitCompose(routerHistory) {
media_attributes,
sensitive: getState().getIn(['compose', 'sensitive']) || (spoilerText.length > 0 && media.size !== 0),
spoiler_text: spoilerText,
visibility: getState().getIn(['compose', 'privacy']),
visibility: overridePrivacy || getState().getIn(['compose', 'privacy']),
poll: getState().getIn(['compose', 'poll'], null),
language: getState().getIn(['compose', 'language']),
},
Expand All @@ -246,11 +239,6 @@ export function submitCompose(routerHistory) {
dispatch(insertIntoTagHistory(response.data.tags, status));
dispatch(submitComposeSuccess({ ...response.data }));

// If the response has no data then we can't do anything else.
if (!response.data) {
return;
}

// To make the app more responsive, immediately push the status
// into the columns
const insertIfOnline = timelineId => {
Expand Down Expand Up @@ -660,31 +648,35 @@ export const readyComposeSuggestionsTags = (token, tags) => ({

export function selectComposeSuggestion(position, token, suggestion, path) {
return (dispatch, getState) => {
let completion;
let completion, startPosition;

if (suggestion.type === 'emoji') {
completion = suggestion.native || suggestion.colons;
completion = suggestion.native || suggestion.colons;
startPosition = position - 1;

dispatch(useEmoji(suggestion));
} else if (suggestion.type === 'hashtag') {
completion = `#${suggestion.name}`;
completion = `#${suggestion.name}`;
startPosition = position - 1;
} else if (suggestion.type === 'account') {
completion = '@' + getState().getIn(['accounts', suggestion.id, 'acct']);
completion = getState().getIn(['accounts', suggestion.id, 'acct']);
startPosition = position;
}

// We don't want to replace hashtags that vary only in case due to accessibility, but we need to fire off an event so that
// the suggestions are dismissed and the cursor moves forward.
if (suggestion.type !== 'hashtag' || token.slice(1).localeCompare(suggestion.name, undefined, { sensitivity: 'accent' }) !== 0) {
dispatch({
type: COMPOSE_SUGGESTION_SELECT,
position,
position: startPosition,
token,
completion,
path,
});
} else {
dispatch({
type: COMPOSE_SUGGESTION_IGNORE,
position,
position: startPosition,
token,
completion,
path,
Expand Down Expand Up @@ -786,18 +778,26 @@ export function changeComposeVisibility(value) {
};
}

export function changeComposeContentType(value) {
export function insertEmojiCompose(position, emoji, needsSpace) {
return {
type: COMPOSE_CONTENT_TYPE_CHANGE,
type: COMPOSE_EMOJI_INSERT,
position,
emoji,
needsSpace,
};
}

export function changeComposing(value) {
return {
type: COMPOSE_COMPOSING_CHANGE,
value,
};
}

export function insertEmojiCompose(position, emoji) {
export function changeComposeContentType(value) {
return {
type: COMPOSE_EMOJI_INSERT,
position,
emoji,
type: COMPOSE_CONTENT_TYPE_CHANGE,
value,
};
}

Expand Down
8 changes: 4 additions & 4 deletions app/javascript/flavours/glitch/components/account.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ class Account extends ImmutablePureComponent {
static propTypes = {
size: PropTypes.number,
account: ImmutablePropTypes.record,
onFollow: PropTypes.func.isRequired,
onBlock: PropTypes.func.isRequired,
onMute: PropTypes.func.isRequired,
onMuteNotifications: PropTypes.func.isRequired,
onFollow: PropTypes.func,
onBlock: PropTypes.func,
onMute: PropTypes.func,
onMuteNotifications: PropTypes.func,
intl: PropTypes.object.isRequired,
hidden: PropTypes.bool,
minimal: PropTypes.bool,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default class AutosuggestEmoji extends PureComponent {
alt={emoji.native || emoji.colons}
/>

{emoji.colons}
<div className='autosuggest-emoji__name'>{emoji.colons}</div>
</div>
);
}
Expand Down
37 changes: 13 additions & 24 deletions app/javascript/flavours/glitch/components/autosuggest_hashtag.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { FormattedMessage } from 'react-intl';

import { ShortNumber } from 'flavours/glitch/components/short_number';

interface Props {
Expand All @@ -16,27 +14,18 @@ interface Props {
};
}

export const AutosuggestHashtag: React.FC<Props> = ({ tag }) => {
const weeklyUses = tag.history && (
<ShortNumber
value={tag.history.reduce((total, day) => total + day.uses * 1, 0)}
/>
);
export const AutosuggestHashtag: React.FC<Props> = ({ tag }) => (
<div className='autosuggest-hashtag'>
<div className='autosuggest-hashtag__name'>
#<strong>{tag.name}</strong>
</div>

return (
<div className='autosuggest-hashtag'>
<div className='autosuggest-hashtag__name'>
#<strong>{tag.name}</strong>
{tag.history !== undefined && (
<div className='autosuggest-hashtag__uses'>
<ShortNumber
value={tag.history.reduce((total, day) => total + day.uses * 1, 0)}
/>
</div>
{tag.history !== undefined && (
<div className='autosuggest-hashtag__uses'>
<FormattedMessage
id='autosuggest_hashtag.per_week'
defaultMessage='{count} per week'
values={{ count: weeklyUses }}
/>
</div>
)}
</div>
);
};
)}
</div>
);
67 changes: 36 additions & 31 deletions app/javascript/flavours/glitch/components/autosuggest_input.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import classNames from 'classnames';
import ImmutablePropTypes from 'react-immutable-proptypes';
import ImmutablePureComponent from 'react-immutable-pure-component';

import Overlay from 'react-overlays/Overlay';

import AutosuggestAccountContainer from '../features/compose/containers/autosuggest_account_container';

import AutosuggestEmoji from './autosuggest_emoji';
Expand All @@ -13,8 +15,8 @@ import { AutosuggestHashtag } from './autosuggest_hashtag';
const textAtCursorMatchesToken = (str, caretPosition, searchTokens) => {
let word;

let left = str.slice(0, caretPosition).search(/[^\s\u200B]+$/);
let right = str.slice(caretPosition).search(/[\s\u200B]/);
let left = str.slice(0, caretPosition).search(/\S+$/);
let right = str.slice(caretPosition).search(/\s/);

if (right < 0) {
word = str.slice(left);
Expand All @@ -29,7 +31,7 @@ const textAtCursorMatchesToken = (str, caretPosition, searchTokens) => {
word = word.trim().toLowerCase();

if (word.length > 0) {
return [left, word];
return [left + 1, word];
} else {
return [null, null];
}
Expand Down Expand Up @@ -195,34 +197,37 @@ export default class AutosuggestInput extends ImmutablePureComponent {

return (
<div className='autosuggest-input'>
<label>
<span style={{ display: 'none' }}>{placeholder}</span>

<input
type='text'
ref={this.setInput}
disabled={disabled}
placeholder={placeholder}
autoFocus={autoFocus}
value={value}
onChange={this.onChange}
onKeyDown={this.onKeyDown}
onKeyUp={onKeyUp}
onFocus={this.onFocus}
onBlur={this.onBlur}
dir='auto'
aria-autocomplete='list'
id={id}
className={className}
maxLength={maxLength}
lang={lang}
spellCheck={spellCheck}
/>
</label>

<div className={`autosuggest-textarea__suggestions ${suggestionsHidden || suggestions.isEmpty() ? '' : 'autosuggest-textarea__suggestions--visible'}`}>
{suggestions.map(this.renderSuggestion)}
</div>
<input
type='text'
ref={this.setInput}
disabled={disabled}
placeholder={placeholder}
autoFocus={autoFocus}
value={value}
onChange={this.onChange}
onKeyDown={this.onKeyDown}
onKeyUp={onKeyUp}
onFocus={this.onFocus}
onBlur={this.onBlur}
dir='auto'
aria-autocomplete='list'
aria-label={placeholder}
id={id}
className={className}
maxLength={maxLength}
lang={lang}
spellCheck={spellCheck}
/>

<Overlay show={!(suggestionsHidden || suggestions.isEmpty())} offset={[0, 0]} placement='bottom' target={this.input} popperConfig={{ strategy: 'fixed' }}>
{({ props }) => (
<div {...props}>
<div className='autosuggest-textarea__suggestions' style={{ width: this.input?.clientWidth }}>
{suggestions.map(this.renderSuggestion)}
</div>
</div>
)}
</Overlay>
</div>
);
}
Expand Down
Loading
Loading