Swapping out iframely.

This commit is contained in:
Dessalines 2021-08-17 20:31:46 -04:00
parent 62e410c382
commit 2943e6e1a5
4 changed files with 875 additions and 1268 deletions

View file

@ -69,7 +69,7 @@
"husky": "^7.0.1",
"import-sort-style-module": "^6.0.0",
"iso-639-1": "^2.1.9",
"lemmy-js-client": "0.11.4-rc.10",
"lemmy-js-client": "0.11.4-rc.12",
"lint-staged": "^11.0.1",
"mini-css-extract-plugin": "^2.1.0",
"node-fetch": "^2.6.1",

View file

@ -28,7 +28,7 @@ import {
communityToChoice,
debounce,
fetchCommunities,
getPageTitle,
getSiteMetadata,
isBrowser,
isImage,
pictrsDeleteToast,
@ -414,8 +414,8 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
WebSocketService.Instance.send(wsClient.search(form));
// Fetch the page title
getPageTitle(this.state.postForm.url).then(d => {
this.state.suggestedTitle = d;
getSiteMetadata(this.state.postForm.url).then(d => {
this.state.suggestedTitle = d.metadata.title;
this.setState(this.state);
});
} else {

View file

@ -2,6 +2,7 @@ import emojiShortName from "emoji-short-name";
import {
CommentView,
CommunityView,
GetSiteMetadata,
GetSiteResponse,
LemmyHttp,
LemmyWebsocket,
@ -328,10 +329,12 @@ export function routeSearchTypeToEnum(type: string): SearchType {
return SearchType[type];
}
export async function getPageTitle(url: string) {
let res = await fetch(`/iframely/oembed?url=${url}`).then(res => res.json());
let title = await res.title;
return title;
export async function getSiteMetadata(url: string) {
let form: GetSiteMetadata = {
url,
};
let client = new LemmyHttp(httpBase);
return client.getSiteMetadata(form);
}
export function debounce(func: any, wait = 1000, immediate = false) {

2124
yarn.lock

File diff suppressed because it is too large Load diff