Skip to content

Commit 68db127

Browse files
committed
fix(cherry-chat): update webview domain and logging
1 parent 53e5170 commit 68db127

2 files changed

Lines changed: 16 additions & 7 deletions

File tree

frontend/NextVibe/components/Chat/ChatScreen.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ export default function ChatScreen() {
140140
embedUrl: 'https://embed.cherry.fun'
141141
};
142142

143+
console.log("[ChatScreen] Loading Cherry Chat with Room:", config.roomId, "WalletAddress passed:", config.walletAddress, "Token:", token);
144+
143145
return (
144146
<View style={[styles.container, { backgroundColor: isDark ? '#0A0410' : '#fff' }]}>
145147
<StatusBar backgroundColor={isDark ? "#0A0410" : "#fff"} />
@@ -169,7 +171,7 @@ export default function ChatScreen() {
169171
) : errorMsg ? (
170172
<View style={styles.center}>
171173
<Text style={[styles.errorText]}>{errorMsg}</Text>
172-
<TouchableOpacity style={styles.retryButton} onPress={() => fetchToken(walletAddress)}>
174+
<TouchableOpacity style={styles.retryButton} onPress={() => { setErrorMsg(null); fetchToken(walletAddress); }}>
173175
<Text style={styles.retryButtonText}>Retry</Text>
174176
</TouchableOpacity>
175177
</View>
@@ -182,7 +184,7 @@ export default function ChatScreen() {
182184
</View>
183185
) : (
184186
<CherryChatWebView
185-
source={{ html: hostHtml, baseUrl: 'https://embed.cherry.fun' }}
187+
source={{ html: hostHtml, baseUrl: 'https://nextvibe.io' }}
186188
config={config}
187189
onSign={onSign}
188190
onWalletConnectRequested={onWalletConnectRequested}
@@ -191,6 +193,8 @@ export default function ChatScreen() {
191193
console.log(`[CherryChat] Event: ${event}`, data);
192194
if (event === 'error') {
193195
console.error("[CherryChat] Error payload:", data);
196+
const errMsg = data?.message || data?.code || (typeof data === 'string' ? data : JSON.stringify(data)) || "Unknown error";
197+
setErrorMsg(`Cherry Error: ${errMsg}`);
194198
}
195199
}}
196200
/>

frontend/NextVibe/components/Chat/cherryHostHtml.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,20 +99,25 @@ export function buildCherryHostHtml({ sdkUrl }: BuildCherryHostHtmlOptions): str
9999
return;
100100
}
101101
102-
chat = new SDK.CherryEmbed({
102+
var embedOpts = {
103103
appId: cfg.appId,
104104
container: '#chat',
105105
roomId: cfg.roomId || undefined,
106106
mode: cfg.mode || undefined,
107107
token: cfg.token || undefined,
108-
walletAddress: cfg.walletAddress || undefined,
109108
embedUrl: cfg.embedUrl || undefined,
110109
theme: cfg.theme || undefined,
111110
layout: cfg.layout || undefined,
112-
signChallengeHandler: function (messageBytes) {
111+
};
112+
113+
if (cfg.walletAddress) {
114+
embedOpts.walletAddress = cfg.walletAddress;
115+
embedOpts.signChallengeHandler = function (messageBytes) {
113116
return requestSignatureFromNative(messageBytes);
114-
},
115-
});
117+
};
118+
}
119+
120+
chat = new SDK.CherryEmbed(embedOpts);
116121
117122
var events = ['ready', 'authStateChange', 'unreadCount', 'message', 'tokenExpired', 'error', 'walletConnectRequested', 'preview', 'roomChanged'];
118123
events.forEach(function (ev) {

0 commit comments

Comments
 (0)