Skip to content

Commit

Permalink
MDE/PKFE-46 implemented socket emit in [FE]
Browse files Browse the repository at this point in the history
  • Loading branch information
mantvydasdeltuva committed Sep 10, 2024
1 parent e2e9c48 commit 845047d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import {
} from '@/features/editor/components/fileTreeView/fileTreeItem';
import { useWorkspaceContext } from '@/features/editor/hooks';
import { FileTreeItemContextMenuActions, FileTreeViewItemProps, FileTypes } from '@/features/editor/types';
import { axios } from '@/lib';
import { Endpoints } from '@/types';
import { axios, socket } from '@/lib';
import { Endpoints, Events } from '@/types';
import { getSID, getUUID } from '@/utils';
import { Divider, Menu, MenuItem } from '@mui/material';
import { useCallback, useState } from 'react';

Expand Down Expand Up @@ -174,9 +175,9 @@ export const FileTreeItemContextMenu: React.FC<FileTreeItemContextMenuProps> = (
link.click();
window.URL.revokeObjectURL(url);

// TODO: Implement socket console event for successful file export
console.log('Exported:', fileName);
socket.emit(Events.WORKSPACE_EXPORT_FEEDBACK_EVENT, { uuid: getUUID(), sid: getSID(), status: 'success' });
} catch (error) {
socket.emit(Events.WORKSPACE_EXPORT_FEEDBACK_EVENT, { uuid: getUUID(), sid: getSID(), status: 'failure' });
console.error('Error exporting file:', error);
}
}, [item]);
Expand Down
3 changes: 3 additions & 0 deletions app/front-end/src/types/constants/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@
* - `CONSOLE_FEEDBACK_EVENT`: The event name for console feedback messages.
* - `WORKSPACE_FILE_SAVE_FEEDBACK_EVENT`: The event name for feedback related to saving files in the workspace.
* - `WORKSPACE_UPDATE_FEEDBACK_EVENT`: The event name for feedback related to updates in the workspace.
* - `WORKSPACE_EXPORT_FEEDBACK_EVENT`: The event name for feedback related to exporting the workspace.
*
* @constant {Object} Events - The object containing event names.
* @property {string} CONSOLE_FEEDBACK_EVENT - The event name for receiving console feedback messages.
* @property {string} WORKSPACE_FILE_SAVE_FEEDBACK_EVENT - The event name for receiving feedback on file save operations within the workspace.
* @property {string} WORKSPACE_UPDATE_FEEDBACK_EVENT - The event name for receiving feedback on workspace updates.
* @property {string} WORKSPACE_EXPORT_FEEDBACK_EVENT - The event name for receiving feedback on exporting the workspace.
*
* @example
* // Example usage of the Events object
Expand All @@ -26,4 +28,5 @@ export const Events = {
CONSOLE_FEEDBACK_EVENT: 'console_feedback',
WORKSPACE_FILE_SAVE_FEEDBACK_EVENT: 'workspace_file_save_feedback',
WORKSPACE_UPDATE_FEEDBACK_EVENT: 'workspace_update_feedback',
WORKSPACE_EXPORT_FEEDBACK_EVENT: 'workspace_export_feedback',
};

0 comments on commit 845047d

Please sign in to comment.