kopia lustrzana https://gitlab.com/soapbox-pub/soapbox
WIP: embeds
rodzic
2ea13e2582
commit
37a8bc7083
|
@ -368,11 +368,14 @@ class ActionBar extends React.PureComponent<IActionBar, IActionBarState> {
|
|||
action: this.handleCopy,
|
||||
icon: require('@tabler/icons/icons/link.svg'),
|
||||
});
|
||||
// menu.push({
|
||||
// text: intl.formatMessage(messages.embed),
|
||||
// action: this.handleEmbed,
|
||||
// icon: require('feather-icons/dist/icons/link-2.svg'),
|
||||
// });
|
||||
|
||||
if (features.embeds) {
|
||||
menu.push({
|
||||
text: intl.formatMessage(messages.embed),
|
||||
action: this.handleEmbed,
|
||||
icon: require('feather-icons/dist/icons/link-2.svg'),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (me) {
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
import axios from 'axios';
|
||||
import PropTypes from 'prop-types';
|
||||
import React from 'react';
|
||||
import ImmutablePureComponent from 'react-immutable-pure-component';
|
||||
import { FormattedMessage, injectIntl } from 'react-intl';
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
export default @injectIntl
|
||||
import api from 'soapbox/api';
|
||||
|
||||
export default @connect()
|
||||
@injectIntl
|
||||
class EmbedModal extends ImmutablePureComponent {
|
||||
|
||||
static propTypes = {
|
||||
|
@ -19,12 +22,18 @@ class EmbedModal extends ImmutablePureComponent {
|
|||
oembed: null,
|
||||
};
|
||||
|
||||
componentDidMount() {
|
||||
const { url } = this.props;
|
||||
fetchEmbed = () => {
|
||||
const { dispatch, url } = this.props;
|
||||
|
||||
return dispatch((dispatch, getState) => {
|
||||
return api(getState).get('/api/oembed', { params: { url } });
|
||||
});
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.setState({ loading: true });
|
||||
|
||||
axios.post('/api/web/embed', { url }).then(res => {
|
||||
this.fetchEmbed().then(res => {
|
||||
this.setState({ loading: false, oembed: res.data });
|
||||
|
||||
const iframeDocument = this.iframe.contentWindow.document;
|
||||
|
|
|
@ -30,6 +30,7 @@ const getInstanceFeatures = (instance: Instance) => {
|
|||
privacyScopes: v.software !== TRUTHSOCIAL,
|
||||
spoilers: v.software !== TRUTHSOCIAL,
|
||||
filters: v.software !== TRUTHSOCIAL,
|
||||
embeds: v.software === MASTODON,
|
||||
polls: any([
|
||||
v.software === MASTODON && gte(v.version, '2.8.0'),
|
||||
v.software === PLEROMA,
|
||||
|
|
Ładowanie…
Reference in New Issue