Skip to content

Commit

Permalink
chore: renaming conversation to chatbot
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas Burtey committed Mar 28, 2024
1 parent baaaf16 commit a35e629
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 31 deletions.
29 changes: 13 additions & 16 deletions .storybook/storybook.requires.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
/* do not change this file, it is auto generated by storybook. */

import { argsEnhancers } from "@storybook/addon-actions/dist/modern/preset/addArgs"
import "@storybook/addon-ondevice-actions/register"
import "@storybook/addon-ondevice-backgrounds/register"
import "@storybook/addon-ondevice-controls/register"
import "@storybook/addon-ondevice-knobs/register"
import "@storybook/addon-ondevice-notes/register"
import {
configure,
addDecorator,
addParameters,
addArgsEnhancer,
clearDecorators,
} from "@storybook/react-native";
} from "@storybook/react-native"

global.STORIES = [
{
Expand All @@ -16,18 +21,10 @@ global.STORIES = [
importPathMatcher:
"^\\.[\\\\/](?:app(?:\\/(?!\\.)(?:(?:(?!(?:^|\\/)\\.).)*?)\\/|\\/|$)(?!\\.)(?=.)[^/]*?\\.stories\\.(?:ts|tsx)?)$",
},
];

import "@storybook/addon-ondevice-notes/register";
import "@storybook/addon-ondevice-controls/register";
import "@storybook/addon-ondevice-knobs/register";
import "@storybook/addon-ondevice-backgrounds/register";
import "@storybook/addon-ondevice-actions/register";

import { argsEnhancers } from "@storybook/addon-actions/dist/modern/preset/addArgs";
]

try {
argsEnhancers.forEach((enhancer) => addArgsEnhancer(enhancer));
argsEnhancers.forEach((enhancer) => addArgsEnhancer(enhancer))
} catch {}

const getStories = () => {
Expand Down Expand Up @@ -67,7 +64,7 @@ const getStories = () => {
"./app/screens/authentication-screen/authentication-check-screen.stories.tsx": require("../app/screens/authentication-screen/authentication-check-screen.stories.tsx"),
"./app/screens/authentication-screen/authentication-screen.stories.tsx": require("../app/screens/authentication-screen/authentication-screen.stories.tsx"),
"./app/screens/authentication-screen/pin-screen.stories.tsx": require("../app/screens/authentication-screen/pin-screen.stories.tsx"),
"./app/screens/conversation/conversation.stories.tsx": require("../app/screens/conversation/conversation.stories.tsx"),
"./app/screens/conversation/conversation.stories.tsx": require("../app/screens/chatbot-screen/chatbot.stories.tsx"),
"./app/screens/conversion-flow/conversion-success-screen.stories.tsx": require("../app/screens/conversion-flow/conversion-success-screen.stories.tsx"),
"./app/screens/earns-map-screen/earns-map-screen.stories.tsx": require("../app/screens/earns-map-screen/earns-map-screen.stories.tsx"),
"./app/screens/earns-screen/earns-quiz.stories.tsx": require("../app/screens/earns-screen/earns-quiz.stories.tsx"),
Expand Down Expand Up @@ -104,7 +101,7 @@ const getStories = () => {
"./app/screens/settings-screen/settings-screen.stories.tsx": require("../app/screens/settings-screen/settings-screen.stories.tsx"),
"./app/screens/settings-screen/theme-screen.stories.tsx": require("../app/screens/settings-screen/theme-screen.stories.tsx"),
"./app/screens/transaction-detail-screen/transaction-detail-screen.stories.tsx": require("../app/screens/transaction-detail-screen/transaction-detail-screen.stories.tsx"),
};
};
}
}

configure(getStories, module, false);
configure(getStories, module, false)
2 changes: 1 addition & 1 deletion .storybook/storybook.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ RNBootSplash.hide({ fade: true })
const StorybookUI = getStorybookUI({
enableWebsockets: true,
onDeviceUI: true,
initialSelection: { kind: "Conversation Screen", name: "Default" },
initialSelection: { kind: "ChatBot Screen", name: "Default" },
shouldPersistSelection: false,
})

Expand Down
4 changes: 2 additions & 2 deletions app/navigation/root-navigator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import LearnIcon from "@app/assets/icons/learn.svg"
import MapIcon from "@app/assets/icons/map.svg"
import { useIsAuthed } from "@app/graphql/is-authed-context"
import { useI18nContext } from "@app/i18n/i18n-react"
import { ConversationScreen } from "@app/screens/conversation/conversation"
import { ChatBotScreen } from "@app/screens/chatbot-screen/chatbot"
import {
ConversionConfirmationScreen,
ConversionDetailsScreen,
Expand Down Expand Up @@ -412,7 +412,7 @@ export const RootStack = () => {
/>
<RootNavigator.Screen
name="chatbot"
component={ConversationScreen}
component={ChatBotScreen}
options={{
title: LL.support.chatbot(),
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { StoryScreen } from "../../../.storybook/views"
import { createCache } from "../../graphql/cache"
import { SupportChatDocument } from "../../graphql/generated"
import { IsAuthedContextProvider } from "../../graphql/is-authed-context"
import { ConversationScreen } from "./conversation"
import { ChatBotScreen } from "./chatbot"

const mockEmpty = [
{
Expand Down Expand Up @@ -61,23 +61,23 @@ const mockShort = [
]

export default {
title: "Conversation Screen",
component: ConversationScreen,
title: "ChatBot Screen",
component: ChatBotScreen,
decorators: [(Story) => <StoryScreen>{Story()}</StoryScreen>],
} as Meta<typeof ConversationScreen>
} as Meta<typeof ChatBotScreen>

export const Empty = () => (
<MockedProvider mocks={mockEmpty} cache={createCache()}>
<IsAuthedContextProvider value={true}>
<ConversationScreen />
<ChatBotScreen />
</IsAuthedContextProvider>
</MockedProvider>
)

export const Default = () => (
<MockedProvider mocks={mockShort} cache={createCache()}>
<IsAuthedContextProvider value={true}>
<ConversationScreen />
<ChatBotScreen />
</IsAuthedContextProvider>
</MockedProvider>
)
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useState, useRef } from "react"
import {
ActivityIndicator,
Alert,
FlatList,
Keyboard,
TouchableHighlight,
Expand Down Expand Up @@ -55,7 +56,7 @@ gql`
}
`

export const ConversationScreen = () => {
export const ChatBotScreen = () => {
const styles = useStyles()
const { theme } = useTheme()

Expand Down Expand Up @@ -102,13 +103,10 @@ export const ConversationScreen = () => {
await supportChatMessageAdd({
variables: { input: { message: input } },
update: (cache, { data }) => {
// If mutation didn't return any data, return early
if (!data || !data.supportChatMessageAdd.supportMessage) return

// Add the new message to the chat array
const newMessages = data.supportChatMessageAdd.supportMessage

// Write the updated chats back to the cache
cache.writeQuery({
query: SupportChatDocument,
data: {
Expand All @@ -120,10 +118,18 @@ export const ConversationScreen = () => {
},
})
} catch (err) {
// TODO: translation
Alert.alert("Error", "An error occurred while sending the message")
console.log("error: ", err)
} finally {
setPendingInput("")
setTimeout(() => {
// TODO: improve code clarity
// supportChatMaybeInput should be the "cache" version prior to the table update
// and length will increase by 1 after the update
// so I think supportChatMaybeInput.length - 1
// is actually mapping to supportChatMaybeInput.length - 2
// when consideing the new message
const indexBeforeLast = supportChatMaybeInput.length - 1
if (indexBeforeLast >= 0) {
flatListRef.current?.scrollToIndex({ index: indexBeforeLast, animated: true })
Expand All @@ -136,12 +142,13 @@ export const ConversationScreen = () => {
setInput(v)
}

// TODO: make it work
async function clearChat() {
if (loading) return
// setOpenaiResponse([])
setInput("")
}

// FIXME: this is not working
async function showClipboardActionsheet(text: string) {
console.log("showClipboardActionsheet", text)

Expand Down
1 change: 0 additions & 1 deletion app/screens/settings-screen/settings-screen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ export const SettingsScreen: React.FC = () => {
skip: !isAtLeastLevelZero,
})

// get beta flag
const betaQuery = useBetaQuery()
const beta = betaQuery.data?.beta ?? false

Expand Down

0 comments on commit a35e629

Please sign in to comment.