Porównaj commity

...

7 Commity

Autor SHA1 Wiadomość Data
Chee Aun 51457302f8
Merge pull request #506 from cheeaun/main
Update from main
2024-04-19 09:18:55 +08:00
Lim Chee Aun 7376cb1e99 Fix muted="false" means still muted 🤦‍♂️🤦‍♂️🤦‍♂️ 2024-04-19 08:46:10 +08:00
Lim Chee Aun ffbae70178 Remove newline from regex for shortcode 2024-04-19 08:41:16 +08:00
Lim Chee Aun 9235d2c800 Hide poll button if maxOptions <= 1
It's not a poll if there's only 1 option
2024-04-18 23:12:29 +08:00
Lim Chee Aun 6ccefaebe1 Handle invalid date
Ugly solution for now, but it's already ugly
2024-04-18 23:11:18 +08:00
Lim Chee Aun 5a448c8049 Fix infinite reloading
Comment these out because this used to fix an old bug with instances not loaded properly
2024-04-18 23:10:26 +08:00
Lim Chee Aun 9bf77fa97a Mentions also need fixNotifications
It's also from notifications API
2024-04-18 17:15:51 +08:00
6 zmienionych plików z 35 dodań i 22 usunięć

Wyświetl plik

@ -131,7 +131,7 @@ const HASHTAG_RE = new RegExp(
// https://github.com/mastodon/mastodon/blob/23e32a4b3031d1da8b911e0145d61b4dd47c4f96/app/models/custom_emoji.rb#L31 // https://github.com/mastodon/mastodon/blob/23e32a4b3031d1da8b911e0145d61b4dd47c4f96/app/models/custom_emoji.rb#L31
const SHORTCODE_RE_FRAGMENT = '[a-zA-Z0-9_]{2,}'; const SHORTCODE_RE_FRAGMENT = '[a-zA-Z0-9_]{2,}';
const SCAN_RE = new RegExp( 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', 'g',
); );
@ -1219,22 +1219,30 @@ function Compose({
/> />
<Icon icon="attachment" /> <Icon icon="attachment" />
</label>{' '} </label>{' '}
<button {/* If maxOptions is not defined or defined and is greater than 1, show poll button */}
type="button" {maxOptions == null ||
class="toolbar-button" (maxOptions > 1 && (
disabled={ <>
uiState === 'loading' || !!poll || !!mediaAttachments.length <button
} type="button"
onClick={() => { class="toolbar-button"
setPoll({ disabled={
options: ['', ''], uiState === 'loading' ||
expiresIn: 24 * 60 * 60, // 1 day !!poll ||
multiple: false, !!mediaAttachments.length
}); }
}} onClick={() => {
> setPoll({
<Icon icon="poll" alt="Add poll" /> options: ['', ''],
</button>{' '} expiresIn: 24 * 60 * 60, // 1 day
multiple: false,
});
}}
>
<Icon icon="poll" alt="Add poll" />
</button>{' '}
</>
))}
<button <button
type="button" type="button"
class="toolbar-button" class="toolbar-button"

Wyświetl plik

@ -388,7 +388,7 @@ function Media({
data-orientation="${orientation}" data-orientation="${orientation}"
preload="auto" preload="auto"
autoplay autoplay
muted="${isGIF}" ${isGIF ? 'muted' : ''}
${isGIF ? '' : 'controls'} ${isGIF ? '' : 'controls'}
playsinline playsinline
loop="${loopable}" loop="${loopable}"

Wyświetl plik

@ -21,6 +21,7 @@ export default function RelativeTime({ datetime, format }) {
const [renderCount, rerender] = useReducer((x) => x + 1, 0); const [renderCount, rerender] = useReducer((x) => x + 1, 0);
const date = useMemo(() => dayjs(datetime), [datetime]); const date = useMemo(() => dayjs(datetime), [datetime]);
const [dateStr, dt, title] = useMemo(() => { const [dateStr, dt, title] = useMemo(() => {
if (!date.isValid()) return ['' + datetime, '', ''];
let str; let str;
if (format === 'micro') { if (format === 'micro') {
// If date <= 1 day ago or day is within this year // If date <= 1 day ago or day is within this year
@ -37,6 +38,7 @@ export default function RelativeTime({ datetime, format }) {
}, [date, format, renderCount]); }, [date, format, renderCount]);
useEffect(() => { useEffect(() => {
if (!date.isValid()) return;
let timeout; let timeout;
let raf; let raf;
function rafRerender() { function rafRerender() {

Wyświetl plik

@ -4,6 +4,7 @@ import { useSearchParams } from 'react-router-dom';
import Link from '../components/link'; import Link from '../components/link';
import Timeline from '../components/timeline'; import Timeline from '../components/timeline';
import { api } from '../utils/api'; import { api } from '../utils/api';
import { fixNotifications } from '../utils/group-notifications';
import { saveStatus } from '../utils/states'; import { saveStatus } from '../utils/states';
import useTitle from '../utils/useTitle'; import useTitle from '../utils/useTitle';
@ -30,6 +31,8 @@ function Mentions({ columnMode, ...props }) {
const results = await mentionsIterator.current.next(); const results = await mentionsIterator.current.next();
let { value } = results; let { value } = results;
if (value?.length) { if (value?.length) {
value = fixNotifications(value);
if (firstLoad) { if (firstLoad) {
latestItem.current = value[0].id; latestItem.current = value[0].id;
console.log('First load', latestItem.current); console.log('First load', latestItem.current);

Wyświetl plik

@ -9,7 +9,7 @@ const notificationTypeKeys = {
poll: ['status'], poll: ['status'],
update: ['status'], update: ['status'],
}; };
function fixNotifications(notifications) { export function fixNotifications(notifications) {
return notifications.filter((notification) => { return notifications.filter((notification) => {
const { type, id, createdAt } = notification; const { type, id, createdAt } = notification;
if (!type) { if (!type) {

Wyświetl plik

@ -107,10 +107,10 @@ export function getCurrentInstance() {
return (currentInstance = instances[instance]); return (currentInstance = instances[instance]);
} catch (e) { } catch (e) {
console.error(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 // Temporary fix for corrupted data
store.local.del('instances'); // store.local.del('instances');
location.reload(); // location.reload();
return {}; return {};
} }
} }