Porównaj commity

...

9 Commity

Autor SHA1 Wiadomość Data
Helge c58fb71939
Merge 99e5c1036d into 7376cb1e99 2024-04-20 00:34:56 +02: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
Lim Chee Aun b9058c6e3d Debounced auto-submit for GIF search field 2024-04-17 08:26:35 +08:00
Helge 99e5c1036d Enable running using http
This means that by adding PHANPY_SCHEME=http to the file ".env"
phanpy will use http instead of https to connect to remote instances.

This is useful to test local versions of various Fediverse applications.
These can be created following the instructions on

https://funfedi.dev/quickstart/#running-an-application-from-the-fediverse-pasture
2024-03-09 17:31:36 +01:00
9 zmienionych plików z 59 dodań i 32 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
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',
);
@ -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"
@ -2374,6 +2382,10 @@ function GIFPickerModal({ onClose = () => {}, onSelect = () => {} }) {
qRef.current?.focus();
}, []);
const debouncedOnInput = useDebouncedCallback(() => {
fetchGIFs({ offset: 0 });
}, 1000);
return (
<div id="gif-picker-sheet" class="sheet">
{!!onClose && (
@ -2400,6 +2412,7 @@ function GIFPickerModal({ onClose = () => {}, onSelect = () => {} }) {
autocapitalize="off"
spellCheck="false"
dir="auto"
onInput={debouncedOnInput}
/>
<input
type="image"

Wyświetl plik

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

Wyświetl plik

@ -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
@ -37,6 +38,7 @@ export default function RelativeTime({ datetime, format }) {
}, [date, format, renderCount]);
useEffect(() => {
if (!date.isValid()) return;
let timeout;
let raf;
function rafRerender() {

Wyświetl plik

@ -12,7 +12,7 @@ import { getAuthorizationURL, registerApplication } from '../utils/auth';
import store from '../utils/store';
import useTitle from '../utils/useTitle';
const { PHANPY_DEFAULT_INSTANCE: DEFAULT_INSTANCE } = import.meta.env;
const { PHANPY_DEFAULT_INSTANCE: DEFAULT_INSTANCE, PHANPY_SCHEME: SCHEME = 'https' } = import.meta.env;
function Login() {
useTitle('Log in');
@ -85,9 +85,11 @@ function Login() {
.replace(/^@?[^@]+@/, '') // Remove @?acct@
.trim()
: null;
const instanceTextLooksLikeDomain =
/[^\s\r\n\t\/\\]+\.[^\s\r\n\t\/\\]+/.test(cleanInstanceText) &&
!/[\s\/\\@]/.test(cleanInstanceText);
const instanceTextLooksLikeDomain =
(/[^\s\r\n\t\/\\]+\.[^\s\r\n\t\/\\]+/.test(cleanInstanceText) &&
!/[\s\/\\@]/.test(cleanInstanceText)) || SCHEME === "http";
console.log(SCHEME)
const instancesSuggestions = cleanInstanceText
? instancesList

Wyświetl plik

@ -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';
@ -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);

Wyświetl plik

@ -10,6 +10,8 @@ import {
setCurrentAccountID,
} from './store-utils';
const { PHANPY_SCHEME: SCHEME = 'https' } = import.meta.env;
// Default *fallback* instance
const DEFAULT_INSTANCE = 'mastodon.social';
@ -37,7 +39,9 @@ export function initClient({ instance, accessToken }) {
.replace(/\/+$/, '')
.toLowerCase();
}
const url = instance ? `https://${instance}` : `https://${DEFAULT_INSTANCE}`;
const url = instance
? `${SCHEME}://${instance}`
: `${SCHEME}://${DEFAULT_INSTANCE}`;
const masto = createRestAPIClient({
url,

Wyświetl plik

@ -1,5 +1,8 @@
const { PHANPY_CLIENT_NAME: CLIENT_NAME, PHANPY_WEBSITE: WEBSITE } = import.meta
.env;
const {
PHANPY_CLIENT_NAME: CLIENT_NAME,
PHANPY_WEBSITE: WEBSITE,
PHANPY_SCHEME: SCHEME = 'https',
} = import.meta.env;
const SCOPES = 'read write follow push';
@ -11,7 +14,7 @@ export async function registerApplication({ instanceURL }) {
website: WEBSITE,
});
const registrationResponse = await fetch(
`https://${instanceURL}/api/v1/apps`,
`${SCHEME}://${instanceURL}/api/v1/apps`,
{
method: 'POST',
headers: {
@ -33,7 +36,7 @@ export async function getAuthorizationURL({ instanceURL, client_id }) {
// redirect_uri: 'urn:ietf:wg:oauth:2.0:oob',
response_type: 'code',
});
const authorizationURL = `https://${instanceURL}/oauth/authorize?${authorizationParams.toString()}`;
const authorizationURL = `${SCHEME}://${instanceURL}/oauth/authorize?${authorizationParams.toString()}`;
return authorizationURL;
}
@ -51,7 +54,7 @@ export async function getAccessToken({
code,
scope: SCOPES,
});
const tokenResponse = await fetch(`https://${instanceURL}/oauth/token`, {
const tokenResponse = await fetch(`${SCHEME}://${instanceURL}/oauth/token`, {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',

Wyświetl plik

@ -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) {

Wyświetl plik

@ -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 {};
}
}