mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-03-23 14:13:21 +01:00
Fix composer not opening for Pleroma instances
Pleroma doesn't have `configuration` in instance API response
This commit is contained in:
parent
7555bda8e9
commit
0247c041f2
2 changed files with 55 additions and 6 deletions
|
@ -23,6 +23,7 @@ import {
|
||||||
getCurrentAccount,
|
getCurrentAccount,
|
||||||
getCurrentAccountNS,
|
getCurrentAccountNS,
|
||||||
getCurrentInstance,
|
getCurrentInstance,
|
||||||
|
getCurrentInstanceConfiguration,
|
||||||
} from '../utils/store-utils';
|
} from '../utils/store-utils';
|
||||||
import supports from '../utils/supports';
|
import supports from '../utils/supports';
|
||||||
import useInterval from '../utils/useInterval';
|
import useInterval from '../utils/useInterval';
|
||||||
|
@ -119,21 +120,30 @@ function Compose({
|
||||||
const currentAccount = getCurrentAccount();
|
const currentAccount = getCurrentAccount();
|
||||||
const currentAccountInfo = currentAccount.info;
|
const currentAccountInfo = currentAccount.info;
|
||||||
|
|
||||||
const { configuration } = getCurrentInstance();
|
const configuration = getCurrentInstanceConfiguration();
|
||||||
console.log('⚙️ Configuration', configuration);
|
console.log('⚙️ Configuration', configuration);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
statuses: { maxCharacters, maxMediaAttachments, charactersReservedPerUrl },
|
statuses: {
|
||||||
|
maxCharacters,
|
||||||
|
maxMediaAttachments,
|
||||||
|
charactersReservedPerUrl,
|
||||||
|
} = {},
|
||||||
mediaAttachments: {
|
mediaAttachments: {
|
||||||
supportedMimeTypes,
|
supportedMimeTypes = [],
|
||||||
imageSizeLimit,
|
imageSizeLimit,
|
||||||
imageMatrixLimit,
|
imageMatrixLimit,
|
||||||
videoSizeLimit,
|
videoSizeLimit,
|
||||||
videoMatrixLimit,
|
videoMatrixLimit,
|
||||||
videoFrameRateLimit,
|
videoFrameRateLimit,
|
||||||
},
|
} = {},
|
||||||
polls: { maxOptions, maxCharactersPerOption, maxExpiration, minExpiration },
|
polls: {
|
||||||
} = configuration;
|
maxOptions,
|
||||||
|
maxCharactersPerOption,
|
||||||
|
maxExpiration,
|
||||||
|
minExpiration,
|
||||||
|
} = {},
|
||||||
|
} = configuration || {};
|
||||||
|
|
||||||
const textareaRef = useRef();
|
const textareaRef = useRef();
|
||||||
const spoilerTextRef = useRef();
|
const spoilerTextRef = useRef();
|
||||||
|
|
|
@ -81,3 +81,42 @@ export function getCurrentInstance() {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Massage these instance configurations to match the Mastodon API
|
||||||
|
// - Pleroma
|
||||||
|
function getInstanceConfiguration(instance) {
|
||||||
|
const {
|
||||||
|
configuration,
|
||||||
|
maxMediaAttachments,
|
||||||
|
maxTootChars,
|
||||||
|
pleroma,
|
||||||
|
pollLimits,
|
||||||
|
} = instance;
|
||||||
|
|
||||||
|
const statuses = configuration?.statuses || {};
|
||||||
|
if (maxMediaAttachments) {
|
||||||
|
statuses.maxMediaAttachments ??= maxMediaAttachments;
|
||||||
|
}
|
||||||
|
if (maxTootChars) {
|
||||||
|
statuses.maxCharacters ??= maxTootChars;
|
||||||
|
}
|
||||||
|
|
||||||
|
const polls = configuration?.polls || {};
|
||||||
|
if (pollLimits) {
|
||||||
|
polls.maxCharactersPerOption ??= pollLimits.maxOptionChars;
|
||||||
|
polls.maxExpiration ??= pollLimits.maxExpiration;
|
||||||
|
polls.maxOptions ??= pollLimits.maxOptions;
|
||||||
|
polls.minExpiration ??= pollLimits.minExpiration;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
...configuration,
|
||||||
|
statuses,
|
||||||
|
polls,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getCurrentInstanceConfiguration() {
|
||||||
|
const instance = getCurrentInstance();
|
||||||
|
return getInstanceConfiguration(instance);
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue