Skip to content

Commit

Permalink
Merge pull request #506 from cheeaun/main
Browse files Browse the repository at this point in the history
Update from main
  • Loading branch information
cheeaun committed Apr 19, 2024
2 parents b6cf53c + 7376cb1 commit 5145730
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 22 deletions.
42 changes: 25 additions & 17 deletions src/components/compose.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ const HASHTAG_RE = new RegExp(
// https://github.com/mastodon/mastodon/blob/23e32a4b3031d1da8b911e0145d61b4dd47c4f96/app/models/custom_emoji.rb#L31
const SHORTCODE_RE_FRAGMENT = '[a-zA-Z0-9_]{2,}';
const SCAN_RE = new RegExp(
`([^A-Za-z0-9_:\\n]|^)(:${SHORTCODE_RE_FRAGMENT}:)(?=[^A-Za-z0-9_:]|$)`,
`(^|[^=\\/\\w])(:${SHORTCODE_RE_FRAGMENT}:)(?=[^A-Za-z0-9_:]|$)`,
'g',
);

Expand Down Expand Up @@ -1219,22 +1219,30 @@ function Compose({
/>
<Icon icon="attachment" />
</label>{' '}
<button
type="button"
class="toolbar-button"
disabled={
uiState === 'loading' || !!poll || !!mediaAttachments.length
}
onClick={() => {
setPoll({
options: ['', ''],
expiresIn: 24 * 60 * 60, // 1 day
multiple: false,
});
}}
>
<Icon icon="poll" alt="Add poll" />
</button>{' '}
{/* If maxOptions is not defined or defined and is greater than 1, show poll button */}
{maxOptions == null ||
(maxOptions > 1 && (
<>
<button
type="button"
class="toolbar-button"
disabled={
uiState === 'loading' ||
!!poll ||
!!mediaAttachments.length
}
onClick={() => {
setPoll({
options: ['', ''],
expiresIn: 24 * 60 * 60, // 1 day
multiple: false,
});
}}
>
<Icon icon="poll" alt="Add poll" />
</button>{' '}
</>
))}
<button
type="button"
class="toolbar-button"
Expand Down
2 changes: 1 addition & 1 deletion src/components/media.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ function Media({
data-orientation="${orientation}"
preload="auto"
autoplay
muted="${isGIF}"
${isGIF ? 'muted' : ''}
${isGIF ? '' : 'controls'}
playsinline
loop="${loopable}"
Expand Down
2 changes: 2 additions & 0 deletions src/components/relative-time.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default function RelativeTime({ datetime, format }) {
const [renderCount, rerender] = useReducer((x) => x + 1, 0);
const date = useMemo(() => dayjs(datetime), [datetime]);
const [dateStr, dt, title] = useMemo(() => {
if (!date.isValid()) return ['' + datetime, '', ''];
let str;
if (format === 'micro') {
// If date <= 1 day ago or day is within this year
Expand All @@ -37,6 +38,7 @@ export default function RelativeTime({ datetime, format }) {
}, [date, format, renderCount]);

useEffect(() => {
if (!date.isValid()) return;
let timeout;
let raf;
function rafRerender() {
Expand Down
3 changes: 3 additions & 0 deletions src/pages/mentions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useSearchParams } from 'react-router-dom';
import Link from '../components/link';
import Timeline from '../components/timeline';
import { api } from '../utils/api';
import { fixNotifications } from '../utils/group-notifications';
import { saveStatus } from '../utils/states';
import useTitle from '../utils/useTitle';

Expand All @@ -30,6 +31,8 @@ function Mentions({ columnMode, ...props }) {
const results = await mentionsIterator.current.next();
let { value } = results;
if (value?.length) {
value = fixNotifications(value);

if (firstLoad) {
latestItem.current = value[0].id;
console.log('First load', latestItem.current);
Expand Down
2 changes: 1 addition & 1 deletion src/utils/group-notifications.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const notificationTypeKeys = {
poll: ['status'],
update: ['status'],
};
function fixNotifications(notifications) {
export function fixNotifications(notifications) {
return notifications.filter((notification) => {
const { type, id, createdAt } = notification;
if (!type) {
Expand Down
6 changes: 3 additions & 3 deletions src/utils/store-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,10 @@ export function getCurrentInstance() {
return (currentInstance = instances[instance]);
} catch (e) {
console.error(e);
alert(`Failed to load instance configuration. Please try again.\n\n${e}`);
// alert(`Failed to load instance configuration. Please try again.\n\n${e}`);
// Temporary fix for corrupted data
store.local.del('instances');
location.reload();
// store.local.del('instances');
// location.reload();
return {};
}
}
Expand Down

0 comments on commit 5145730

Please sign in to comment.