chore: remove link preview cache feature flag (#12568)

This commit is contained in:
donteatfriedrice
2025-05-27 10:07:32 +00:00
parent 69c7767003
commit af3c002022
6 changed files with 3 additions and 46 deletions

View File

@@ -21,7 +21,6 @@ export interface BlockSuiteFlags {
enable_table_virtual_scroll: boolean; enable_table_virtual_scroll: boolean;
enable_embed_doc_with_alias: boolean; enable_embed_doc_with_alias: boolean;
enable_turbo_renderer: boolean; enable_turbo_renderer: boolean;
enable_link_preview_cache: boolean;
enable_dom_renderer: boolean; enable_dom_renderer: boolean;
} }
@@ -48,7 +47,6 @@ export class FeatureFlagService extends StoreExtension {
enable_table_virtual_scroll: false, enable_table_virtual_scroll: false,
enable_embed_doc_with_alias: false, enable_embed_doc_with_alias: false,
enable_turbo_renderer: false, enable_turbo_renderer: false,
enable_link_preview_cache: false,
enable_dom_renderer: false, enable_dom_renderer: false,
}); });

View File

@@ -1,12 +1,10 @@
import { type LinkPreviewData } from '@blocksuite/affine-model'; import { type LinkPreviewData } from '@blocksuite/affine-model';
import { type Container, createIdentifier } from '@blocksuite/global/di'; import { type Container, createIdentifier } from '@blocksuite/global/di';
import { BlockSuiteError, ErrorCode } from '@blocksuite/global/exceptions'; import { BlockSuiteError, ErrorCode } from '@blocksuite/global/exceptions';
import { type BlockStdScope, StdIdentifier } from '@blocksuite/std';
import { Extension } from '@blocksuite/store'; import { Extension } from '@blocksuite/store';
import { DEFAULT_LINK_PREVIEW_ENDPOINT } from '../../consts'; import { DEFAULT_LINK_PREVIEW_ENDPOINT } from '../../consts';
import { isAbortError } from '../../utils/is-abort-error'; import { isAbortError } from '../../utils/is-abort-error';
import { FeatureFlagService } from '../feature-flag-service';
import { import {
LinkPreviewCacheIdentifier, LinkPreviewCacheIdentifier,
type LinkPreviewCacheProvider, type LinkPreviewCacheProvider,
@@ -53,17 +51,13 @@ export class LinkPreviewService
{ {
static override setup(di: Container) { static override setup(di: Container) {
di.addImpl(LinkPreviewServiceIdentifier, LinkPreviewService, [ di.addImpl(LinkPreviewServiceIdentifier, LinkPreviewService, [
StdIdentifier,
LinkPreviewCacheIdentifier, LinkPreviewCacheIdentifier,
]); ]);
} }
private _endpoint: string = DEFAULT_LINK_PREVIEW_ENDPOINT; private _endpoint: string = DEFAULT_LINK_PREVIEW_ENDPOINT;
constructor( constructor(private readonly _cache: LinkPreviewCacheProvider) {
private readonly _std: BlockStdScope,
private readonly _cache: LinkPreviewCacheProvider
) {
super(); super();
} }
@@ -181,15 +175,6 @@ export class LinkPreviewService
url: string, url: string,
signal?: AbortSignal signal?: AbortSignal
): Promise<Partial<LinkPreviewData>> => { ): Promise<Partial<LinkPreviewData>> => {
const featureFlagService = this._std.store.get(FeatureFlagService);
const cacheEnabled = featureFlagService.getFlag(
'enable_link_preview_cache'
);
// If the cache is not enabled, fetch the preview directly
if (!cacheEnabled) {
return this._fetchPreview(url, signal);
}
// Check memory cache, if hit, return the cached data // Check memory cache, if hit, return the cached data
const cached = this._cache.get(url); const cached = this._cache.get(url);
if (cached) { if (cached) {

View File

@@ -5,7 +5,6 @@ import {
LinkPreviewService, LinkPreviewService,
LinkPreviewServiceIdentifier, LinkPreviewServiceIdentifier,
} from '@blocksuite/affine/shared/services'; } from '@blocksuite/affine/shared/services';
import { type BlockStdScope, StdIdentifier } from '@blocksuite/affine/std';
import { type ExtensionType } from '@blocksuite/affine/store'; import { type ExtensionType } from '@blocksuite/affine/store';
import type { Container } from '@blocksuite/global/di'; import type { Container } from '@blocksuite/global/di';
import type { FrameworkProvider } from '@toeverything/infra'; import type { FrameworkProvider } from '@toeverything/infra';
@@ -13,12 +12,8 @@ import type { FrameworkProvider } from '@toeverything/infra';
import { ServerService } from '../../../modules/cloud/services/server'; import { ServerService } from '../../../modules/cloud/services/server';
class AffineLinkPreviewService extends LinkPreviewService { class AffineLinkPreviewService extends LinkPreviewService {
constructor( constructor(endpoint: string, cache: LinkPreviewCacheProvider) {
endpoint: string, super(cache);
std: BlockStdScope,
cache: LinkPreviewCacheProvider
) {
super(std, cache);
this.setEndpoint(endpoint); this.setEndpoint(endpoint);
} }
} }
@@ -52,7 +47,6 @@ export function patchLinkPreviewService(
di.override(LinkPreviewServiceIdentifier, provider => { di.override(LinkPreviewServiceIdentifier, provider => {
return new AffineLinkPreviewService( return new AffineLinkPreviewService(
linkPreviewUrl, linkPreviewUrl,
provider.get(StdIdentifier),
provider.get(LinkPreviewCacheIdentifier) provider.get(LinkPreviewCacheIdentifier)
); );
}); });

View File

@@ -106,16 +106,6 @@ export const AFFINE_FLAGS = {
configurable: isCanaryBuild, configurable: isCanaryBuild,
defaultState: isCanaryBuild, defaultState: isCanaryBuild,
}, },
enable_link_preview_cache: {
category: 'blocksuite',
bsFlag: 'enable_link_preview_cache',
displayName:
'com.affine.settings.workspace.experimental-features.enable-link-preview-cache.name',
description:
'com.affine.settings.workspace.experimental-features.enable-link-preview-cache.description',
configurable: isCanaryBuild,
defaultState: isCanaryBuild,
},
enable_emoji_folder_icon: { enable_emoji_folder_icon: {
category: 'affine', category: 'affine',

View File

@@ -5778,14 +5778,6 @@ export function useAFFiNEI18N(): {
* `Let your words stand out. This also include the callout in the transcription block.` * `Let your words stand out. This also include the callout in the transcription block.`
*/ */
["com.affine.settings.workspace.experimental-features.enable-callout.description"](): string; ["com.affine.settings.workspace.experimental-features.enable-callout.description"](): string;
/**
* `Link Preview Cache`
*/
["com.affine.settings.workspace.experimental-features.enable-link-preview-cache.name"](): string;
/**
* `Once enabled, the link preview will be cached and cached data will be used when the same link is fetched again. Otherwise, the link preview will be fetched every time.`
*/
["com.affine.settings.workspace.experimental-features.enable-link-preview-cache.description"](): string;
/** /**
* `Embed Iframe Block` * `Embed Iframe Block`
*/ */

View File

@@ -1443,8 +1443,6 @@
"com.affine.settings.workspace.experimental-features.enable-block-meta.description": "Once enabled, all blocks will have created time, updated time, created by and updated by.", "com.affine.settings.workspace.experimental-features.enable-block-meta.description": "Once enabled, all blocks will have created time, updated time, created by and updated by.",
"com.affine.settings.workspace.experimental-features.enable-callout.name": "Callout", "com.affine.settings.workspace.experimental-features.enable-callout.name": "Callout",
"com.affine.settings.workspace.experimental-features.enable-callout.description": "Let your words stand out. This also include the callout in the transcription block.", "com.affine.settings.workspace.experimental-features.enable-callout.description": "Let your words stand out. This also include the callout in the transcription block.",
"com.affine.settings.workspace.experimental-features.enable-link-preview-cache.name": "Link Preview Cache",
"com.affine.settings.workspace.experimental-features.enable-link-preview-cache.description": "Once enabled, the link preview will be cached and cached data will be used when the same link is fetched again. Otherwise, the link preview will be fetched every time.",
"com.affine.settings.workspace.experimental-features.enable-embed-iframe-block.name": "Embed Iframe Block", "com.affine.settings.workspace.experimental-features.enable-embed-iframe-block.name": "Embed Iframe Block",
"com.affine.settings.workspace.experimental-features.enable-embed-iframe-block.description": "Enables Embed Iframe Block.", "com.affine.settings.workspace.experimental-features.enable-embed-iframe-block.description": "Enables Embed Iframe Block.",
"com.affine.settings.workspace.experimental-features.enable-emoji-folder-icon.name": "Emoji Folder Icon", "com.affine.settings.workspace.experimental-features.enable-emoji-folder-icon.name": "Emoji Folder Icon",