Skip to content

Commit 4317315

Browse files
committed
Fixed localstorage loading blocks and change AI tab name, plug fixed initial Google login with no folders
1 parent 14064b4 commit 4317315

6 files changed

Lines changed: 25 additions & 21 deletions

File tree

src/components/blockly.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,9 @@ function BlocklyEditor({ name }: BlocklyEditorProps) {
285285
// There appears to be some timing issues in loading the content into the workspace
286286
// Set 100 ms delay to accommendate the timing issue
287287
const loadEditor = (name: string, content: string) => {
288-
const loadContent = { name: name, content: content};
288+
const lines: string[] | undefined = content.split('##XRPBLOCKS ');
289+
const blockContent = lines.length > 1 ? lines[1] : lines[0];
290+
const loadContent = { name: name, content: blockContent };
289291
AppMgr.getInstance().emit(EventType.EVENT_EDITOR_LOAD, JSON.stringify(loadContent));
290292
};
291293
setTimeout(loadEditor, 100, name, editorSession.content);

src/components/navbar.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -737,14 +737,14 @@ function NavBar({ layoutref }: NavBarProps) {
737737
if (EditorMgr.getInstance().hasEditorSession(Constants.AI_CHAT_TAB_ID)) {
738738
const layoutModel = EditorMgr.getInstance().getLayoutModel();
739739
layoutModel?.doAction(Actions.selectTab(Constants.AI_CHAT_TAB_ID));
740-
setActiveTab('AI Chat');
740+
setActiveTab(t('ai-chat'));
741741
return;
742742
};
743743
const tabInfo: IJsonTabNode = {
744744
component: 'aichat',
745-
name: 'AI Chat',
745+
name: 'ai-chat',
746746
id: Constants.AI_CHAT_TAB_ID,
747-
helpText: 'Chat with AI models from Hugging Face',
747+
helpText: t('ai-chat-help'),
748748
};
749749
layoutref!.current?.addTabToTabSet(Constants.EDITOR_TABSET_ID, tabInfo);
750750
EditorMgr.getInstance().AddEditor({
@@ -759,7 +759,7 @@ function NavBar({ layoutref }: NavBarProps) {
759759
isModified: false,
760760
});
761761
setIsOtherTab(true);
762-
setActiveTab('AI Chat');
762+
setActiveTab(t('ai-chat'));
763763
}
764764

765765
/**

src/managers/editormgr.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ export default class EditorMgr {
281281
path: session.path,
282282
gpath: session.gpath,
283283
isBlockly: session.type === EditorType.BLOCKLY,
284-
isSavedToXRP: !session.isModified,
284+
isSavedToXRP: session.isModified,
285285
content: code,
286286
};
287287
// Update the session content with the new code

src/utils/i18n/locales/en/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@
4949
"selectUserOption": "Select a User",
5050
"myview": "My View",
5151
"settings": "Settings",
52-
"ai-chat": "AI Chat",
52+
"ai-chat": "AI Buddy",
53+
"ai-chat-help": "Chat with XRPCode Buddy",
5354
"user-folder": "User Folder Name",
5455
"google-drive-folder": "Google Drive Folder Name",
5556
"googleLoginTooltip": "Sign in with your Google account to access files stored in Google Drive.",

src/utils/i18n/locales/es/es.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@
4949
"selectUserOption": "Seleccione un Usuario",
5050
"myview": "Mi Vista",
5151
"settings": "Configuración",
52-
"ai-chat": "Chat IA",
52+
"ai-chat": "Código AI",
53+
"ai-chat-help": "Chat con el Compañero de Código XRP",
5354
"user-folder": "Nombre de Carpeta de Usuario",
5455
"google-drive-folder": "Nombre de Carpeta de Google Drive",
5556
"not-google-drive-file": "¡Este archivo no se puede guardar en Google Drive porque no se asocia con Google Drive! Por favor intente guardar el archivo en XRP!",

src/widgets/login.tsx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,6 @@ function Login({ logoutCallback, onSuccess }: LoginProps) {
6363
expire_in: token.expires_in,
6464
}));
6565
driveService.setAccessToken(token.access_token);
66-
// check if XRPCode folder exists, if not create it
67-
try {
68-
const folder = await driveService.findFolderByName(Constants.XRPCODE);
69-
if (!folder) {
70-
await driveService.createFolder(Constants.XRPCODE);
71-
}
72-
} catch (error) {
73-
if (error instanceof Error) {
74-
loginLogger.error(`Error checking or creating XRPCode folder: ${error.stack ?? error.message}`);
75-
} else {
76-
loginLogger.error(`Error checking or creating XRPCode folder: ${String(error)}`);
77-
}
78-
}
7966
});
8067

8168
if (user.refresh_token) {
@@ -130,6 +117,19 @@ function Login({ logoutCallback, onSuccess }: LoginProps) {
130117
.then(async (data) => {
131118
setUserProfile(data);
132119
authService.userProfile = data;
120+
// check if XRPCode folder exists, if not create it
121+
try {
122+
const folder = await driveService.findFolderByName(Constants.XRPCODE);
123+
if (!folder) {
124+
await driveService.createFolder(Constants.XRPCODE);
125+
}
126+
} catch (error) {
127+
if (error instanceof Error) {
128+
loginLogger.error(`Error checking or creating XRPCode folder: ${error.stack ?? error.message}`);
129+
} else {
130+
loginLogger.error(`Error checking or creating XRPCode folder: ${String(error)}`);
131+
}
132+
}
133133
onSuccess(data);
134134
})
135135
.catch((err) => loginLogger.error('Error fetching user profile:', err));

0 commit comments

Comments
 (0)