Skip to content

Commit

Permalink
stop things from imploding
Browse files Browse the repository at this point in the history
  • Loading branch information
Ember committed Jul 11, 2023
1 parent ce26eb8 commit 50fadeb
Show file tree
Hide file tree
Showing 7 changed files with 2 additions and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';

import { Icon } from './icon';

const formatNumber = (num: number): number | string => (num > 40 ? '40+' : num);
//const formatNumber = (num: number): number | string => (num > 40 ? '40+' : num);

interface Props {
id: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import DropdownMenuContainer from 'flavours/glitch/containers/dropdown_menu_cont
import { me, maxReactions } from 'flavours/glitch/initial_state';
import { PERMISSION_MANAGE_USERS, PERMISSION_MANAGE_FEDERATION } from 'flavours/glitch/permissions';
import { accountAdminLink, statusAdminLink } from 'flavours/glitch/utils/backend_links';
import EmojiPickerDropdown from '../../compose/containers/emoji_picker_dropdown_container';

import EmojiPickerDropdown from '../../compose/containers/emoji_picker_dropdown_container';

Expand Down
2 changes: 1 addition & 1 deletion app/javascript/flavours/glitch/features/status/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ import StatusContainer from 'flavours/glitch/containers/status_container';
import BundleColumnError from 'flavours/glitch/features/ui/components/bundle_column_error';
import Column from 'flavours/glitch/features/ui/components/column';
import { boostModal, favouriteModal, deleteModal } from 'flavours/glitch/initial_state';
import { makeCustomEmojiMap, makeGetStatus, makeGetPictureInPicture } from 'flavours/glitch/selectors';
import { makeGetStatus, makeGetPictureInPicture } from 'flavours/glitch/selectors';
import { autoUnfoldCW } from 'flavours/glitch/utils/content_warning';

import ColumnHeader from '../../components/column_header';
Expand Down
35 changes: 0 additions & 35 deletions app/javascript/flavours/glitch/reducers/statuses.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ const updateReaction = (state, id, name, updater) => state.update(
),
);

const updateReactionCount = (state, reaction) => updateReaction(state, reaction.status_id, reaction.name, x => x.set('count', reaction.count));

// The url parameter is only used when adding a new custom emoji reaction
// (one that wasn't in the reactions list before) because we don't have its
// URL yet. In all other cases, it's undefined.
Expand All @@ -102,42 +100,9 @@ const removeReaction = (state, id, name) => updateReaction(
x => x.set('me', false).update('count', n => n - 1),
);

const updateReaction = (state, id, name, updater) => state.update(
id,
status => status.update(
'reactions',
reactions => {
const index = reactions.findIndex(reaction => reaction.get('name') === name);
if (index > -1) {
return reactions.update(index, reaction => updater(reaction));
} else {
return reactions.push(updater(fromJS({ name, count: 0 })));
}
},
),
);

const updateReactionCount = (state, reaction) => updateReaction(state, reaction.status_id, reaction.name, x => x.set('count', reaction.count));

// The url parameter is only used when adding a new custom emoji reaction
// (one that wasn't in the reactions list before) because we don't have its
// URL yet. In all other cases, it's undefined.
const addReaction = (state, id, name, url) => updateReaction(
state,
id,
name,
x => x.set('me', true)
.update('count', n => n + 1)
.update('url', old => old ? old : url)
.update('static_url', old => old ? old : url),
);

const removeReaction = (state, id, name) => updateReaction(
state,
id,
name,
x => x.set('me', false).update('count', n => n - 1),
);

const initialState = ImmutableMap();

Expand Down
1 change: 0 additions & 1 deletion app/javascript/mastodon/components/status.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import { AvatarOverlay } from './avatar_overlay';
import { DisplayName } from './display_name';
import { RelativeTimestamp } from './relative_timestamp';
import StatusActionBar from './status_action_bar';
import StatusReactions from './status_reactions';
import StatusContent from './status_content';
import StatusReactions from './status_reactions';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import ClearColumnButton from './clear_column_button';
import GrantPermissionButton from './grant_permission_button';
import SettingToggle from './setting_toggle';

import PillBarButton from '../../../../flavours/glitch/features/notifications/components/pill_bar_button';

export default class ColumnSettings extends PureComponent {

Expand Down
37 changes: 0 additions & 37 deletions app/javascript/mastodon/reducers/statuses.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,43 +99,6 @@ const removeReaction = (state, id, name) => updateReaction(
x => x.set('me', false).update('count', n => n - 1),
);

const updateReaction = (state, id, name, updater) => state.update(
id,
status => status.update(
'reactions',
reactions => {
const index = reactions.findIndex(reaction => reaction.get('name') === name);
if (index > -1) {
return reactions.update(index, reaction => updater(reaction));
} else {
return reactions.push(updater(fromJS({ name, count: 0 })));
}
},
),
);

const updateReactionCount = (state, reaction) => updateReaction(state, reaction.status_id, reaction.name, x => x.set('count', reaction.count));

// The url parameter is only used when adding a new custom emoji reaction
// (one that wasn't in the reactions list before) because we don't have its
// URL yet. In all other cases, it's undefined.
const addReaction = (state, id, name, url) => updateReaction(
state,
id,
name,
x => x.set('me', true)
.update('count', n => n + 1)
.update('url', old => old ? old : url)
.update('static_url', old => old ? old : url),
);

const removeReaction = (state, id, name) => updateReaction(
state,
id,
name,
x => x.set('me', false).update('count', n => n - 1),
);

const initialState = ImmutableMap();

export default function statuses(state = initialState, action) {
Expand Down

0 comments on commit 50fadeb

Please sign in to comment.