diff --git a/src/app/content/index.tsx b/src/app/content/index.tsx
index a5932d3..a15e0d5 100644
--- a/src/app/content/index.tsx
+++ b/src/app/content/index.tsx
@@ -24,8 +24,8 @@ export default defineContentScript({
const ui = await createShadowRootUi(ctx, {
name: __NAME__,
position: 'inline',
- // anchor: 'body',
- // append: 'first',
+ anchor: 'body',
+ mode: __DEV__ ? 'open' : 'closed',
onMount: (container) => {
const app = createElement('
')
container.append(app)
diff --git a/src/app/content/views/Setup/index.tsx b/src/app/content/views/Setup/index.tsx
index 6d5efe6..534f039 100644
--- a/src/app/content/views/Setup/index.tsx
+++ b/src/app/content/views/Setup/index.tsx
@@ -40,10 +40,8 @@ const generateUserInfo = async (): Promise => {
}
}
-const generateMessage = async (): Promise => {
- const userAvatar = await generateRandomAvatar(MAX_AVATAR_SIZE)
- const username = generateRandomName()
- const userId = nanoid()
+const generateMessage = async (userInfo: UserInfo): Promise => {
+ const { name: username, avatar: userAvatar, id: userId } = userInfo
return {
id: nanoid(),
body: mockTextList.shift()!,
@@ -67,23 +65,28 @@ const Setup: FC = () => {
send(messageListDomain.command.ClearListCommand())
}
- const refreshUserInfo = async () => setUserInfo(await generateUserInfo())
- const createMessage = async () => {
- const message = await generateMessage()
+ const refreshUserInfo = async () => {
+ const userInfo = await generateUserInfo()
+ setUserInfo(userInfo)
+ return userInfo
+ }
+ const createMessage = async (userInfo: UserInfo) => {
+ const message = await generateMessage(userInfo!)
send(messageListDomain.command.CreateItemCommand(message))
}
useEffect(() => {
send(messageListDomain.command.ClearListCommand())
- const userInfoTimer = new Timer(refreshUserInfo, { delay: 2000, immediate: true })
- const messageTimer = new Timer(createMessage, { delay: 2000, immediate: true, limit: mockTextList.length })
+ const timer = new Timer(
+ async () => {
+ const userInfo = await refreshUserInfo()
+ await createMessage(userInfo)
+ },
+ { delay: 2000, immediate: true, limit: mockTextList.length }
+ )
- userInfoTimer.start()
- messageTimer.start()
- return () => {
- userInfoTimer.stop()
- messageTimer.stop()
- }
+ timer.start()
+ return () => timer.stop()
}, [])
return (