Friendica, version parsing fixes
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
parent
66f48ca982
commit
afd4a39337
3 changed files with 8 additions and 6 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
import { List as ImmutableList } from 'immutable';
|
||||||
import React, { useState, useEffect, useMemo } from 'react';
|
import React, { useState, useEffect, useMemo } from 'react';
|
||||||
import { defineMessages, useIntl, FormattedMessage } from 'react-intl';
|
import { defineMessages, useIntl, FormattedMessage } from 'react-intl';
|
||||||
|
|
||||||
|
@ -125,7 +126,7 @@ const accountToCredentials = (account: Account): AccountCredentials => {
|
||||||
display_name: account.display_name,
|
display_name: account.display_name,
|
||||||
note: account.source.get('note'),
|
note: account.source.get('note'),
|
||||||
locked: account.locked,
|
locked: account.locked,
|
||||||
fields_attributes: [...account.source.get<Iterable<AccountCredentialsField>>('fields', []).toJS()],
|
fields_attributes: [...account.source.get<Iterable<AccountCredentialsField>>('fields', ImmutableList()).toJS()],
|
||||||
stranger_notifications: account.getIn(['pleroma', 'notification_settings', 'block_from_strangers']) === true,
|
stranger_notifications: account.getIn(['pleroma', 'notification_settings', 'block_from_strangers']) === true,
|
||||||
accepts_email_list: account.getIn(['pleroma', 'accepts_email_list']) === true,
|
accepts_email_list: account.getIn(['pleroma', 'accepts_email_list']) === true,
|
||||||
hide_followers: hideNetwork,
|
hide_followers: hideNetwork,
|
||||||
|
|
|
@ -624,6 +624,7 @@ const getInstanceFeatures = (instance: Instance) => {
|
||||||
* @see GET /api/v1/timelines/public
|
* @see GET /api/v1/timelines/public
|
||||||
*/
|
*/
|
||||||
publicTimeline: any([
|
publicTimeline: any([
|
||||||
|
v.software === FRIENDICA,
|
||||||
v.software === MASTODON,
|
v.software === MASTODON,
|
||||||
v.software === PLEROMA,
|
v.software === PLEROMA,
|
||||||
v.software === TAKAHE,
|
v.software === TAKAHE,
|
||||||
|
@ -739,7 +740,6 @@ const getInstanceFeatures = (instance: Instance) => {
|
||||||
* @see {@link https://docs.joinmastodon.org/methods/accounts/suggestions/}
|
* @see {@link https://docs.joinmastodon.org/methods/accounts/suggestions/}
|
||||||
*/
|
*/
|
||||||
suggestions: any([
|
suggestions: any([
|
||||||
v.software === FRIENDICA,
|
|
||||||
v.software === MASTODON && gte(v.compatVersion, '2.4.3'),
|
v.software === MASTODON && gte(v.compatVersion, '2.4.3'),
|
||||||
v.software === TRUTHSOCIAL,
|
v.software === TRUTHSOCIAL,
|
||||||
features.includes('v2_suggestions'),
|
features.includes('v2_suggestions'),
|
||||||
|
@ -750,6 +750,7 @@ const getInstanceFeatures = (instance: Instance) => {
|
||||||
* @see GET /api/v2/suggestions
|
* @see GET /api/v2/suggestions
|
||||||
*/
|
*/
|
||||||
suggestionsV2: any([
|
suggestionsV2: any([
|
||||||
|
v.software === FRIENDICA,
|
||||||
v.software === MASTODON && gte(v.compatVersion, '3.4.0'),
|
v.software === MASTODON && gte(v.compatVersion, '3.4.0'),
|
||||||
v.software === TRUTHSOCIAL,
|
v.software === TRUTHSOCIAL,
|
||||||
features.includes('v2_suggestions'),
|
features.includes('v2_suggestions'),
|
||||||
|
@ -830,9 +831,9 @@ export const parseVersion = (version: string): Backend => {
|
||||||
const regex = /^([\w+.]*)(?: \(compatible; ([\w]*) (.*)\))?$/;
|
const regex = /^([\w+.]*)(?: \(compatible; ([\w]*) (.*)\))?$/;
|
||||||
const match = regex.exec(version);
|
const match = regex.exec(version);
|
||||||
|
|
||||||
const semver = match ? semverParse(semverCoerce(match[3] || match[1], { loose: true })) : null;
|
const semverString = match && (match[3] || match[1]);
|
||||||
const compat = match ? semverParse(match[1]) : null;
|
const semver = match ? semverParse(semverString) || semverCoerce(semverString) : null;
|
||||||
|
const compat = match ? semverParse(match[1]) || semverCoerce(match[1]) : null;
|
||||||
|
|
||||||
if (match && semver && compat) {
|
if (match && semver && compat) {
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/** Convert HTML to a plaintext representation, preserving whitespace. */
|
/** Convert HTML to a plaintext representation, preserving whitespace. */
|
||||||
// NB: This function can still return unsafe HTML
|
// NB: This function can still return unsafe HTML
|
||||||
export const unescapeHTML = (html: string): string => {
|
export const unescapeHTML = (html: string = ''): string => {
|
||||||
const wrapper = document.createElement('div');
|
const wrapper = document.createElement('div');
|
||||||
wrapper.innerHTML = html.replace(/<br\s*\/?>/g, '\n').replace(/<\/p><[^>]*>/g, '\n\n').replace(/<[^>]*>/g, '');
|
wrapper.innerHTML = html.replace(/<br\s*\/?>/g, '\n').replace(/<\/p><[^>]*>/g, '\n\n').replace(/<[^>]*>/g, '');
|
||||||
return wrapper.textContent || '';
|
return wrapper.textContent || '';
|
||||||
|
|
Loading…
Reference in a new issue