Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove story oembed API #27

Merged
merged 2 commits into from
May 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 0 additions & 26 deletions src/data-fetching/api/PrezlyApi.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import type {
Category,
ExtendedStory,
ExtraStoryFields,
Newsroom,
NewsroomLanguageSettings,
Story,
} from '@prezly/sdk';
import PrezlySDK from '@prezly/sdk';
import type { StoryBookmarkNode } from '@prezly/slate-types';
import { isStoryBookmarkNode } from '@prezly/slate-types';
import type { IncomingMessage } from 'http';

import { LocaleObject } from '../../intl';
Expand All @@ -25,7 +22,6 @@ import {
} from './languages';
import {
getContactsQuery,
getEmbedStoriesQuery,
getGalleriesQuery,
getSlugQuery,
getSortByPublishedDate,
Expand Down Expand Up @@ -232,28 +228,6 @@ export class PrezlyApi {
return null;
}

/**
* Returns summaries for stories embed in the current story (like in Bookmark Blocks)
* @returns a map of `Story` object with their UUID as keys
*/
async getEmbedStories(story: ExtendedStory) {
const nodes = JSON.parse(story.content);

const embedUuids: Array<string> = await Promise.all(
nodes.children.filter(isStoryBookmarkNode).map((c: StoryBookmarkNode) => c.story.uuid),
);

const jsonQuery = JSON.stringify(getEmbedStoriesQuery(this.newsroomUuid, embedUuids));
const { stories } = await this.searchStories({
jsonQuery,
});

return stories.reduce<Record<Story['uuid'], Story>>(
(result, embedStory) => ({ ...result, [embedStory.uuid]: embedStory }),
{},
);
}

async getNewsroomServerSideProps(
request: IncomingMessage | undefined,
nextLocaleIsoCode?: string,
Expand Down
10 changes: 0 additions & 10 deletions src/data-fetching/api/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,6 @@ export function getSlugQuery(newsroomUuid: string, slug: string) {
};
}

export function getEmbedStoriesQuery(newsroomUuid: string, uuids: string[]) {
return {
$and: [
{ 'newsroom.uuid': { $in: [newsroomUuid] } },
{ uuid: { $in: uuids } },
...publishedAndAccessible,
],
};
}

export function getStoriesQuery(newsroomUuid: string, categoryId?: number, localeCode?: string) {
const query: any = {
$and: [...publishedAndPublic, { 'newsroom.uuid': { $in: [newsroomUuid] } }],
Expand Down
7 changes: 0 additions & 7 deletions src/newsroom-context/context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import type {
NewsroomContact,
NewsroomLanguageSettings,
NewsroomThemePreset,
Story,
} from '@prezly/sdk';
import type { PropsWithChildren } from 'react';
import { createContext, useMemo } from 'react';
Expand Down Expand Up @@ -40,10 +39,6 @@ export interface NewsroomContextType {
* Optional: Refers to a currently selected story when navigated to `/[slug]` page.
*/
currentStory?: ExtendedStory;
/**
* Optional: Embed stories data referenced from the current story content (currently used by Story Bookmark blocks)
*/
embedStories?: Record<Story['uuid'], Story>;
/**
* List of currently enabled newsroom languages, as well as company information translated for each language
*/
Expand Down Expand Up @@ -80,7 +75,6 @@ export function NewsroomContextProvider({
newsroom,
currentCategory,
currentStory,
embedStories,
companyInformation,
languages,
localeCode,
Expand All @@ -101,7 +95,6 @@ export function NewsroomContextProvider({
newsroom,
currentCategory,
currentStory,
embedStories,
companyInformation,
languages,
locale,
Expand Down
1 change: 0 additions & 1 deletion src/newsroom-context/hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ export * from './useCompanyInformation';
export * from './useCurrentCategory';
export * from './useCurrentLocale';
export * from './useCurrentStory';
export * from './useEmbedStory';
export * from './useGetLinkLocaleSlug';
export * from './useGetTranslationUrl';
export * from './useLanguages';
Expand Down
13 changes: 0 additions & 13 deletions src/newsroom-context/hooks/useEmbedStory.ts

This file was deleted.