-
-
Notifications
You must be signed in to change notification settings - Fork 1
feat: 1Password初期化の並列化と非同期サービス設定の実装 #45
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -11,7 +11,7 @@ import SubmitButton from "./component/SubmitButton"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import RelatedListBox from "./component/RelatedListBox"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import ServiceList from "./component/ServiceList"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import AppContext from "./AppContext"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import serviceManger from "./service-instance"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import serviceManger, { waitForInitialization } from "./service-instance"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const ipcRenderer = require("electron").ipcRenderer; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const appContext = new AppContext(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -26,9 +26,24 @@ class App extends React.Component { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| appContext.ServiceStore.state | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // サービスの初期化状態は別管理(ServiceStoreの変更で上書きされないように) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| this._serviceInitialized = false; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| componentDidMount() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| async componentDidMount() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // サービスの初期化を待つ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await waitForInitialization(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| this._serviceInitialized = true; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| this.forceUpdate(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } catch (error) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.error("Failed to initialize services:", error); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // エラーが発生しても表示(シークレットがフォールバック値になる) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| this._serviceInitialized = true; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| this.forceUpdate(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+31
to
+44
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| this._serviceInitialized = false; | |
| } | |
| componentDidMount() { | |
| async componentDidMount() { | |
| // サービスの初期化を待つ | |
| try { | |
| await waitForInitialization(); | |
| this._serviceInitialized = true; | |
| this.forceUpdate(); | |
| } catch (error) { | |
| console.error("Failed to initialize services:", error); | |
| // エラーが発生しても表示(シークレットがフォールバック値になる) | |
| this._serviceInitialized = true; | |
| this.forceUpdate(); | |
| // this._serviceInitialized is now managed in state as 'initialized' | |
| } | |
| async componentDidMount() { | |
| // サービスの初期化を待つ | |
| try { | |
| await waitForInitialization(); | |
| this.setState({ initialized: true }); | |
| } catch (error) { | |
| console.error("Failed to initialize services:", error); | |
| // エラーが発生しても表示(シークレットがフォールバック値になる) | |
| this.setState({ initialized: true }); |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -43,6 +43,13 @@ function createElectronLaunchOptions(additionalArgs = []) { | |||||
| return { args, env, timeout: 30000 }; | ||||||
| } | ||||||
|
|
||||||
| // アプリケーションの初期化完了を待つヘルパー関数 | ||||||
| async function waitForAppInitialization(window) { | ||||||
| // ServiceListが表示されることで初期化完了を確認 | ||||||
| const serviceList = window.locator(".ServiceList"); | ||||||
| await expect(serviceList).toBeVisible({ timeout: 10000 }); | ||||||
| } | ||||||
|
|
||||||
| // Test contextを使用してElectronアプリケーションとウィンドウを管理 | ||||||
| const test = baseTest.extend({ | ||||||
| app: async ({}, use) => { | ||||||
|
|
@@ -75,10 +82,44 @@ test.describe("Postem Application", () => { | |||||
| // メインコンテナが存在することを確認 | ||||||
| const mainDiv = window.locator("#js-main"); | ||||||
| await expect(mainDiv).toBeVisible(); | ||||||
|
|
||||||
| // ローディング画面が表示される可能性があるので、アプリが完全に初期化されるまで待つ | ||||||
| // ServiceListが表示されることで初期化完了を確認 | ||||||
| const serviceList = window.locator(".ServiceList"); | ||||||
| await expect(serviceList).toBeVisible({ timeout: 10000 }); | ||||||
| }); | ||||||
|
|
||||||
| test("ローディング画面が表示され、初期化後に消える", async ({ window }) => { | ||||||
| // ウィンドウが読み込まれるまで待機 | ||||||
| await window.waitForLoadState("domcontentloaded"); | ||||||
|
|
||||||
| // ローディング画面の存在を確認(すぐに確認) | ||||||
| const loadingText = window.locator("text=Loading..."); | ||||||
| const isLoadingVisible = await loadingText.isVisible().catch(() => false); | ||||||
|
||||||
| const isLoadingVisible = await loadingText.isVisible().catch(() => false); | |
| const isLoadingVisible = await loadingText.isVisible(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using instance variable
_serviceInitializedinstead of component state can lead to inconsistent rendering. Consider usingthis.state.serviceInitializedinstead to ensure proper React lifecycle management and re-rendering.