Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

feat(ios): add some apis for native (#9173)

EYHN9a66c97f52c5
diff --git a/packages/frontend/apps/ios/src/app.tsx b/packages/frontend/apps/ios/src/app.tsx
index fb85c5a511..f0254f024b 100644
--- a/packages/frontend/apps/ios/src/app.tsx
+++ b/packages/frontend/apps/ios/src/app.tsx
@@ -9,6 +9,7 @@ import { configureCommonModules } from '@affine/core/modules';
import {
AuthService,
DefaultServerService,
+ ServersService,
ValidatorProvider,
WebSocketAuthProvider,
} from '@affine/core/modules/cloud';
@@ -22,6 +23,7 @@ import {
configureBrowserWorkspaceFlavours,
configureIndexedDBWorkspaceEngineStorageProvider,
} from '@affine/core/modules/workspace-engine';
+import { I18n } from '@affine/i18n';
import { App as CapacitorApp } from '@capacitor/app';
import { Browser } from '@capacitor/browser';
import { Haptics } from '@capacitor/haptics';
@@ -30,6 +32,7 @@ import {
Framework,
FrameworkRoot,
getCurrentStore,
+ GlobalContextService,
LifecycleService,
} from '@toeverything/infra';
import { Suspense } from 'react';
@@ -111,6 +114,21 @@ framework.impl(HapticProvider, {
});
const frameworkProvider = framework.provider();
+// ------ some apis for native ------
+(window as any).getCurrentServerBaseUrl = () => {
+ const globalContextService = frameworkProvider.get(GlobalContextService);
+ const currentServerId = globalContextService.globalContext.serverId.get();
+ const serversService = frameworkProvider.get(ServersService);
+ const defaultServerService = frameworkProvider.get(DefaultServerService);
+ const currentServer =
+ (currentServerId ? serversService.server$(currentServerId).value : null) ??
+ defaultServerService.server;
+ return currentServer.baseUrl;
+};
+(window as any).getCurrentI18nLocale = () => {
+ return I18n.language;
+};
+
// setup application lifecycle events, and emit application start event
window.addEventListener('focus', () => {
frameworkProvider.get(LifecycleService).applicationFocus();