mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-11-24 14:20:28 +00:00
chore: enable AI seach (#7169)
* chore: enable AI seach * chore: remove unused code * fix: replace the old web base url with the new one
This commit is contained in:
parent
6966b303ff
commit
64994b3336
@ -159,7 +159,7 @@ Future<void> _setAppFlowyCloudUrl(String? url) async {
|
|||||||
Future<void> useBaseWebDomain(String? url) async {
|
Future<void> useBaseWebDomain(String? url) async {
|
||||||
await getIt<KeyValueStorage>().set(
|
await getIt<KeyValueStorage>().set(
|
||||||
KVKeys.kAppFlowyBaseShareDomain,
|
KVKeys.kAppFlowyBaseShareDomain,
|
||||||
url ?? ShareConstants.baseWebDomain,
|
url ?? ShareConstants.defaultBaseWebDomain,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
2
frontend/appflowy_flutter/lib/env/env.dart
vendored
2
frontend/appflowy_flutter/lib/env/env.dart
vendored
@ -48,7 +48,7 @@ abstract class Env {
|
|||||||
@EnviedField(
|
@EnviedField(
|
||||||
obfuscate: false,
|
obfuscate: false,
|
||||||
varName: 'BASE_WEB_DOMAIN',
|
varName: 'BASE_WEB_DOMAIN',
|
||||||
defaultValue: ShareConstants.baseWebDomain,
|
defaultValue: ShareConstants.defaultBaseWebDomain,
|
||||||
)
|
)
|
||||||
static const String baseWebDomain = _Env.baseWebDomain;
|
static const String baseWebDomain = _Env.baseWebDomain;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,9 +2,8 @@ import 'package:appflowy/env/cloud_env.dart';
|
|||||||
import 'package:appflowy/startup/startup.dart';
|
import 'package:appflowy/startup/startup.dart';
|
||||||
|
|
||||||
class ShareConstants {
|
class ShareConstants {
|
||||||
static const String baseWebDomain = 'appflowy.com';
|
|
||||||
static const String testBaseWebDomain = 'test.appflowy.com';
|
static const String testBaseWebDomain = 'test.appflowy.com';
|
||||||
static const String defaultBaseWebDomain = 'https://www.appflowy.com';
|
static const String defaultBaseWebDomain = 'https://appflowy.com';
|
||||||
|
|
||||||
static String buildPublishUrl({
|
static String buildPublishUrl({
|
||||||
required String nameSpace,
|
required String nameSpace,
|
||||||
|
|||||||
@ -37,7 +37,7 @@ const _macOSVolumesPattern = '^/Volumes/[^/]+';
|
|||||||
final macOSVolumesRegex = RegExp(_macOSVolumesPattern);
|
final macOSVolumesRegex = RegExp(_macOSVolumesPattern);
|
||||||
|
|
||||||
const appflowySharePageLinkPattern =
|
const appflowySharePageLinkPattern =
|
||||||
r'^https://www\.appflowy\.com/app/([^/]+)/([^?]+)(?:\?blockId=(.+))?$';
|
r'^https://appflowy\.com/app/([^/]+)/([^?]+)(?:\?blockId=(.+))?$';
|
||||||
final appflowySharePageLinkRegex = RegExp(appflowySharePageLinkPattern);
|
final appflowySharePageLinkRegex = RegExp(appflowySharePageLinkPattern);
|
||||||
|
|
||||||
const _numberedListPattern = r'^(\d+)\.';
|
const _numberedListPattern = r'^(\d+)\.';
|
||||||
|
|||||||
@ -1,7 +1,5 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/foundation.dart';
|
|
||||||
|
|
||||||
import 'package:appflowy/plugins/trash/application/trash_listener.dart';
|
import 'package:appflowy/plugins/trash/application/trash_listener.dart';
|
||||||
import 'package:appflowy/plugins/trash/application/trash_service.dart';
|
import 'package:appflowy/plugins/trash/application/trash_service.dart';
|
||||||
import 'package:appflowy/workspace/application/command_palette/search_listener.dart';
|
import 'package:appflowy/workspace/application/command_palette/search_listener.dart';
|
||||||
@ -10,6 +8,7 @@ import 'package:appflowy_backend/protobuf/flowy-folder/trash.pb.dart';
|
|||||||
import 'package:appflowy_backend/protobuf/flowy-search/notification.pb.dart';
|
import 'package:appflowy_backend/protobuf/flowy-search/notification.pb.dart';
|
||||||
import 'package:appflowy_backend/protobuf/flowy-search/result.pb.dart';
|
import 'package:appflowy_backend/protobuf/flowy-search/result.pb.dart';
|
||||||
import 'package:bloc/bloc.dart';
|
import 'package:bloc/bloc.dart';
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||||
|
|
||||||
part 'command_palette_bloc.freezed.dart';
|
part 'command_palette_bloc.freezed.dart';
|
||||||
@ -90,12 +89,9 @@ class CommandPaletteBloc
|
|||||||
|
|
||||||
_messagesReceived++;
|
_messagesReceived++;
|
||||||
|
|
||||||
final searchResults = _filterDuplicates(results.items);
|
|
||||||
searchResults.sort((a, b) => b.score.compareTo(a.score));
|
|
||||||
|
|
||||||
emit(
|
emit(
|
||||||
state.copyWith(
|
state.copyWith(
|
||||||
results: searchResults,
|
results: results.items,
|
||||||
isLoading: _messagesReceived != results.sends.toInt(),
|
isLoading: _messagesReceived != results.sends.toInt(),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -133,31 +129,6 @@ class CommandPaletteBloc
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<SearchResultPB> _filterDuplicates(List<SearchResultPB> results) {
|
|
||||||
final currentItems = [...state.results];
|
|
||||||
final res = [...results];
|
|
||||||
|
|
||||||
for (final item in results) {
|
|
||||||
if (item.data.trim().isEmpty) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
final duplicateIndex = currentItems.indexWhere((a) => a.id == item.id);
|
|
||||||
if (duplicateIndex == -1) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
final duplicate = currentItems[duplicateIndex];
|
|
||||||
if (item.score < duplicate.score) {
|
|
||||||
res.remove(item);
|
|
||||||
} else {
|
|
||||||
currentItems.remove(duplicate);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return res..addAll(currentItems);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _performSearch(String value) =>
|
void _performSearch(String value) =>
|
||||||
add(CommandPaletteEvent.performSearch(search: value));
|
add(CommandPaletteEvent.performSearch(search: value));
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
use flowy_folder::manager::FolderManager;
|
use flowy_folder::manager::FolderManager;
|
||||||
|
use flowy_search::document::handler::DocumentSearchHandler;
|
||||||
use flowy_search::folder::handler::FolderSearchHandler;
|
use flowy_search::folder::handler::FolderSearchHandler;
|
||||||
use flowy_search::folder::indexer::FolderIndexManagerImpl;
|
use flowy_search::folder::indexer::FolderIndexManagerImpl;
|
||||||
use flowy_search::services::manager::SearchManager;
|
use flowy_search::services::manager::SearchManager;
|
||||||
@ -9,11 +10,11 @@ pub struct SearchDepsResolver();
|
|||||||
impl SearchDepsResolver {
|
impl SearchDepsResolver {
|
||||||
pub async fn resolve(
|
pub async fn resolve(
|
||||||
folder_indexer: Arc<FolderIndexManagerImpl>,
|
folder_indexer: Arc<FolderIndexManagerImpl>,
|
||||||
_cloud_service: Arc<dyn SearchCloudService>,
|
cloud_service: Arc<dyn SearchCloudService>,
|
||||||
_folder_manager: Arc<FolderManager>,
|
folder_manager: Arc<FolderManager>,
|
||||||
) -> Arc<SearchManager> {
|
) -> Arc<SearchManager> {
|
||||||
let folder_handler = Arc::new(FolderSearchHandler::new(folder_indexer));
|
let folder_handler = Arc::new(FolderSearchHandler::new(folder_indexer));
|
||||||
// let document_handler = Arc::new(DocumentSearchHandler::new(cloud_service, folder_manager));
|
let document_handler = Arc::new(DocumentSearchHandler::new(cloud_service, folder_manager));
|
||||||
Arc::new(SearchManager::new(vec![folder_handler]))
|
Arc::new(SearchManager::new(vec![folder_handler, document_handler]))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -81,10 +81,7 @@ impl SearchHandler for DocumentSearchHandler {
|
|||||||
id: result.object_id.clone(),
|
id: result.object_id.clone(),
|
||||||
data: view.name.clone(),
|
data: view.name.clone(),
|
||||||
icon,
|
icon,
|
||||||
// We reverse the score, the cloud search score is based on
|
score: result.score,
|
||||||
// 1 being the worst result, and closer to 0 being good result, that is
|
|
||||||
// the opposite of local search.
|
|
||||||
score: 1.0 - result.score,
|
|
||||||
workspace_id: result.workspace_id,
|
workspace_id: result.workspace_id,
|
||||||
preview: result.preview,
|
preview: result.preview,
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user