#4257 Added functionality to create previews for post links using open graph data from those links. (#4890)

Этот коммит содержится в:
Debanshu Kundu
2017-01-20 23:11:13 +05:30
коммит произвёл enahum
родитель fefe4b70d9
Коммит 3aaf71fdea
26 изменённых файлов: 1241 добавлений и 534 удалений

Просмотреть файл

@@ -596,3 +596,27 @@ export function redirectUserToDefaultTeam() {
browserHistory.push('/select_team');
}
}
requestOpenGraphMetadata.openGraphMetadataOnGoingRequests = {}; // Format: {<url>: true}
export function requestOpenGraphMetadata(url) {
const onself = requestOpenGraphMetadata;
if (!onself.openGraphMetadataOnGoingRequests[url]) {
onself.openGraphMetadataOnGoingRequests[url] = true;
Client.getOpenGraphMetadata(url,
(data) => {
AppDispatcher.handleServerAction({
type: ActionTypes.RECIVED_OPEN_GRAPH_METADATA,
url,
data
});
delete onself.openGraphMetadataOnGoingRequests[url];
},
(err) => {
AsyncClient.dispatchError(err, 'getOpenGraphMetadata');
delete onself.openGraphMetadataOnGoingRequests[url];
}
);
}
}