-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): expose toggle ai onboarding apis (#7039)
```ts import { toggleGeneralAIOnboarding } from '@affine/core/components/affine/ai-onboarding/apis'; // show // toggleGeneralAIOnboarding(); toggleGeneralAIOnboarding(true); // dismiss toggleGeneralAIOnboarding(false); ```
- Loading branch information
Showing
6 changed files
with
70 additions
and
49 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
packages/frontend/core/src/components/affine/ai-onboarding/apis.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { AIOnboardingType } from './type'; | ||
|
||
function createStorageEvent(key: string, newValue: string) { | ||
const event = new StorageEvent('storage', { | ||
key, | ||
newValue, | ||
oldValue: localStorage.getItem(key), | ||
storageArea: localStorage, | ||
}); | ||
window.dispatchEvent(event); | ||
} | ||
|
||
const setItem = function (key: string, value: string) { | ||
const oldValue = localStorage.getItem(key); | ||
localStorage.setItem.call(localStorage, key, value); | ||
if (oldValue !== value) createStorageEvent(key, value); | ||
}; | ||
|
||
/** | ||
* Show/Hide AI onboarding manually | ||
*/ | ||
export const toggleGeneralAIOnboarding = (show = true) => { | ||
setItem(AIOnboardingType.GENERAL, show ? 'false' : 'true'); | ||
}; | ||
|
||
/** | ||
* Show/Hide local AI toast manually | ||
*/ | ||
export const toggleLocalAIOnboarding = (show = true) => { | ||
setItem(AIOnboardingType.LOCAL, show ? 'false' : 'true'); | ||
}; | ||
|
||
/** | ||
* Show/Hide edgeless AI toast manually | ||
*/ | ||
export const toggleEdgelessAIOnboarding = (show = true) => { | ||
setItem(AIOnboardingType.EDGELESS, show ? 'false' : 'true'); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 0 additions & 3 deletions
3
packages/frontend/core/src/components/affine/ai-onboarding/type.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters