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
@@ -21,7 +21,6 @@ export interface BlockSuiteFlags {
enable_table_virtual_scroll: boolean;
enable_embed_doc_with_alias: boolean;
enable_turbo_renderer: boolean;
enable_link_preview_cache: boolean;
enable_dom_renderer: boolean;
}
@@ -48,7 +47,6 @@ export class FeatureFlagService extends StoreExtension {
enable_table_virtual_scroll: false,
enable_embed_doc_with_alias: false,
enable_turbo_renderer: false,
enable_link_preview_cache: false,
enable_dom_renderer: false,
});
@@ -1,12 +1,10 @@
import { type LinkPreviewData } from '@blocksuite/affine-model';
import { type Container, createIdentifier } from '@blocksuite/global/di';
import { BlockSuiteError, ErrorCode } from '@blocksuite/global/exceptions';
import { type BlockStdScope, StdIdentifier } from '@blocksuite/std';
import { Extension } from '@blocksuite/store';
import { DEFAULT_LINK_PREVIEW_ENDPOINT } from '../../consts';
import { isAbortError } from '../../utils/is-abort-error';
import { FeatureFlagService } from '../feature-flag-service';
import {
LinkPreviewCacheIdentifier,
type LinkPreviewCacheProvider,
@@ -53,17 +51,13 @@ export class LinkPreviewService
{
static override setup(di: Container) {
di.addImpl(LinkPreviewServiceIdentifier, LinkPreviewService, [
StdIdentifier,
LinkPreviewCacheIdentifier,
]);
}
private _endpoint: string = DEFAULT_LINK_PREVIEW_ENDPOINT;
constructor(
private readonly _std: BlockStdScope,
private readonly _cache: LinkPreviewCacheProvider
) {
constructor(private readonly _cache: LinkPreviewCacheProvider) {
super();
}
@@ -181,15 +175,6 @@ export class LinkPreviewService
url: string,
signal?: AbortSignal
): 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
const cached = this._cache.get(url);
if (cached) {
@@ -5,7 +5,6 @@ import {
LinkPreviewService,
LinkPreviewServiceIdentifier,
} from '@blocksuite/affine/shared/services';
import { type BlockStdScope, StdIdentifier } from '@blocksuite/affine/std';
import { type ExtensionType } from '@blocksuite/affine/store';
import type { Container } from '@blocksuite/global/di';
import type { FrameworkProvider } from '@toeverything/infra';
@@ -13,12 +12,8 @@ import type { FrameworkProvider } from '@toeverything/infra';
import { ServerService } from '../../../modules/cloud/services/server';
class AffineLinkPreviewService extends LinkPreviewService {
constructor(
endpoint: string,
std: BlockStdScope,
cache: LinkPreviewCacheProvider
) {
super(std, cache);
constructor(endpoint: string, cache: LinkPreviewCacheProvider) {
super(cache);
this.setEndpoint(endpoint);
}
}
@@ -52,7 +47,6 @@ export function patchLinkPreviewService(
di.override(LinkPreviewServiceIdentifier, provider => {
return new AffineLinkPreviewService(
linkPreviewUrl,
provider.get(StdIdentifier),
provider.get(LinkPreviewCacheIdentifier)
);
});
@@ -106,16 +106,6 @@ export const AFFINE_FLAGS = {
configurable: 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: {
category: 'affine',
-8
View File
@@ -5778,14 +5778,6 @@ export function useAFFiNEI18N(): {
* `Let your words stand out. This also include the callout in the transcription block.`
*/
["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`
*/
@@ -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-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-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.description": "Enables Embed Iframe Block.",
"com.affine.settings.workspace.experimental-features.enable-emoji-folder-icon.name": "Emoji Folder Icon",