Skip to content

Commit

Permalink
fix: finish using root id utility
Browse files Browse the repository at this point in the history
  • Loading branch information
mikitabut committed Feb 13, 2024
1 parent 7c2dd6c commit 28ec9ac
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 56 deletions.
6 changes: 2 additions & 4 deletions apps/chat/src/components/Chatbar/ChatbarSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { useTranslation } from 'next-i18next';

import { BucketService } from '@/src/utils/app/data/bucket-service';

Check failure on line 12 in apps/chat/src/components/Chatbar/ChatbarSettings.tsx

View workflow job for this annotation

GitHub Actions / run_tests / style_checks

'BucketService' is defined but never used. Allowed unused vars must match /^__/u
import { constructPath } from '@/src/utils/app/file';

Check failure on line 13 in apps/chat/src/components/Chatbar/ChatbarSettings.tsx

View workflow job for this annotation

GitHub Actions / run_tests / style_checks

'constructPath' is defined but never used. Allowed unused vars must match /^__/u
import { getRootId } from '@/src/utils/app/id';
import { ApiKeys } from '@/src/utils/server/api';

import { FeatureType } from '@/src/types/common';
Expand Down Expand Up @@ -89,10 +90,7 @@ export const ChatbarSettings = () => {
onClick: () => {
dispatch(
ConversationsActions.createFolder({
parentId: constructPath(
ApiKeys.Conversations,
BucketService.getBucket(),
),
parentId: getRootId({ apiKey: ApiKeys.Conversations }),
}),
);
},
Expand Down
9 changes: 3 additions & 6 deletions apps/chat/src/components/Chatbar/Conversation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import classNames from 'classnames';

import { BucketService } from '@/src/utils/app/data/bucket-service';

Check failure on line 16 in apps/chat/src/components/Chatbar/Conversation.tsx

View workflow job for this annotation

GitHub Actions / run_tests / style_checks

'BucketService' is defined but never used. Allowed unused vars must match /^__/u
import { constructPath, notAllowedSymbolsRegex } from '@/src/utils/app/file';
import { getRootId } from '@/src/utils/app/id';
import { hasParentWithFloatingOverlay } from '@/src/utils/app/modals';
import { MoveType, getDragImage } from '@/src/utils/app/move';
import { defaultMyItemsFilters } from '@/src/utils/app/search';
Expand Down Expand Up @@ -349,10 +350,7 @@ export const ConversationComponent = ({ item: conversation, level }: Props) => {
if (isNewFolder) {
dispatch(
ConversationsActions.createFolder({
parentId: constructPath(
ApiKeys.Conversations,
BucketService.getBucket(),
),
parentId: getRootId({ apiKey: ApiKeys.Conversations }),
name: newFolderName,
}),
);
Expand All @@ -363,8 +361,7 @@ export const ConversationComponent = ({ item: conversation, level }: Props) => {
values: {
folderId: isNewFolder
? constructPath(
ApiKeys.Conversations,
BucketService.getBucket(),
getRootId({ apiKey: ApiKeys.Conversations }),
folderPath,
)
: folderPath,
Expand Down
14 changes: 4 additions & 10 deletions apps/chat/src/components/Files/PreUploadModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
notAllowedSymbols,
} from '@/src/utils/app/file';
import { getParentAndCurrentFoldersById } from '@/src/utils/app/folders';
import { getRootId } from '@/src/utils/app/id';
import { ApiKeys } from '@/src/utils/server/api';

Check failure on line 27 in apps/chat/src/components/Files/PreUploadModal.tsx

View workflow job for this annotation

GitHub Actions / run_tests / style_checks

'ApiKeys' is defined but never used. Allowed unused vars must match /^__/u

import { DialFile } from '@/src/types/files';
Expand Down Expand Up @@ -147,12 +148,7 @@ export const PreUploadDialog = ({
filteredFiles.map((file) => {
return {
fileContent: file,
id: constructPath(
ApiKeys.Files,
BucketService.getBucket(),
folderPath,
file.name,
),
id: constructPath(getRootId(), folderPath, file.name),
name: file.name,
};
}),
Expand Down Expand Up @@ -251,8 +247,7 @@ export const PreUploadDialog = ({
...file,
name: e.target.value + formatFile,
id: constructPath(
ApiKeys.Files,
BucketService.getBucket(),
getRootId(),
folderPath,
e.target.value + formatFile,
),
Expand Down Expand Up @@ -299,8 +294,7 @@ export const PreUploadDialog = ({
return {
...file,
id: constructPath(
ApiKeys.Files,
BucketService.getBucket(),
getRootId(),
folderPath,
file.name,
),
Expand Down
3 changes: 1 addition & 2 deletions apps/chat/src/components/Promptbar/components/Prompt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,7 @@ export const PromptComponent = ({ item: prompt, level }: Props) => {
values: {
folderId: isNewFolder
? constructPath(
ApiKeys.Prompts,
BucketService.getBucket(),
getRootId({ apiKey: ApiKeys.Prompts }),
folderPath,
)
: folderPath,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { useTranslation } from 'next-i18next';

import { BucketService } from '@/src/utils/app/data/bucket-service';

Check failure on line 10 in apps/chat/src/components/Promptbar/components/PromptbarSettings.tsx

View workflow job for this annotation

GitHub Actions / run_tests / style_checks

'BucketService' is defined but never used. Allowed unused vars must match /^__/u
import { constructPath } from '@/src/utils/app/file';

Check failure on line 11 in apps/chat/src/components/Promptbar/components/PromptbarSettings.tsx

View workflow job for this annotation

GitHub Actions / run_tests / style_checks

'constructPath' is defined but never used. Allowed unused vars must match /^__/u
import { getRootId } from '@/src/utils/app/id';
import { ApiKeys } from '@/src/utils/server/api';

import { FeatureType } from '@/src/types/common';
Expand Down Expand Up @@ -46,10 +47,7 @@ export function PromptbarSettings() {
onClick: () => {
dispatch(
PromptsActions.createFolder({
parentId: constructPath(
ApiKeys.Prompts,
BucketService.getBucket(),
),
parentId: getRootId({ apiKey: ApiKeys.Prompts }),
}),
);
},
Expand Down
10 changes: 2 additions & 8 deletions apps/chat/src/store/conversations/conversations.epics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,10 +295,7 @@ const createNewConversationsEpic: AppEpic = (action$, state$) =>
lastActivityDate: Date.now(),
isMessageStreaming: false,
status: UploadStatus.LOADED,
folderId: constructPath(
ApiKeys.Conversations,
BucketService.getBucket(),
),
folderId: getRootId({ apiKey: ApiKeys.Conversations }),
});
},
);
Expand Down Expand Up @@ -460,10 +457,7 @@ const duplicateConversationEpic: AppEpic = (action$, state$) =>
const newConversation: Conversation = regenerateConversationId({
...conversation,
...resetShareEntity,
folderId: constructPath(
ApiKeys.Conversations,
BucketService.getBucket(),
),
folderId: getRootId({ apiKey: ApiKeys.Conversations }),
name: generateNextName(
DEFAULT_CONVERSATION_NAME,
conversation.name,
Expand Down
5 changes: 1 addition & 4 deletions apps/chat/src/store/conversations/conversations.reducers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,10 +299,7 @@ export const conversationsSlice = createSlice({
const newConversation: Conversation = regenerateConversationId({
...(conversation as Conversation),
...resetShareEntity,
folderId: constructPath(
ApiKeys.Conversations,
BucketService.getBucket(),
),
folderId: getRootId({ apiKey: ApiKeys.Conversations }),
name: generateNextName(
DEFAULT_CONVERSATION_NAME,
conversation.name,
Expand Down
16 changes: 4 additions & 12 deletions apps/chat/src/store/files/files.reducers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
getAvailableNameOnSameFolderLevel,
getParentAndChildFolders,
} from '@/src/utils/app/folders';
import { getRootId } from '@/src/utils/app/id';
import { ApiKeys } from '@/src/utils/server/api';

import { UploadStatus } from '@/src/types/common';
Expand Down Expand Up @@ -57,11 +58,7 @@ export const filesSlice = createSlice({
id: payload.id,
name: payload.name,
relativePath: payload.relativePath,
folderId: constructPath(
ApiKeys.Files,
BucketService.getBucket(),
payload.relativePath,
),
folderId: constructPath(getRootId(), payload.relativePath),

status: UploadStatus.LOADING,
percent: 0,
Expand Down Expand Up @@ -225,20 +222,15 @@ export const filesSlice = createSlice({
);

const newAddedFolderId = constructPath(
ApiKeys.Files,
BucketService.getBucket(),
getRootId(),
payload.relativePath,
folderName,
);
state.folders.push(
addGeneratedFolderId({
name: folderName,
type: FolderType.File,
folderId: constructPath(
ApiKeys.Files,
BucketService.getBucket(),
payload.relativePath,
),
folderId: constructPath(getRootId(), payload.relativePath),
}),
);
state.newAddedFolderId = newAddedFolderId;
Expand Down
4 changes: 2 additions & 2 deletions apps/chat/src/utils/app/conversation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
import { BucketService } from './data/bucket-service';
import { constructPath, notAllowedSymbolsRegex } from './file';
import { compareEntitiesByName, splitEntityId } from './folders';
import { getRootId } from './id';

export const getAssitantModelId = (
modelType: EntityType,
Expand Down Expand Up @@ -114,8 +115,7 @@ export const getGeneratedConversationId = <T extends ConversationInfo>(
);
}
return constructPath(
ApiKeys.Conversations,
BucketService.getBucket(),
getRootId({ apiKey: ApiKeys.Conversations }),
getConversationApiKey(conversation),
);
};
Expand Down
5 changes: 1 addition & 4 deletions apps/chat/src/utils/app/import-export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,7 @@ export function cleanData(data: SupportedExportFormats): CleanDataResponse {
id: chatFolder.id.toString(),
name: chatFolder.name,
type: FolderType.Chat,
folderId: constructPath(
ApiKeys.Conversations,
BucketService.getBucket(),
),
folderId: getRootId({ apiKey: ApiKeys.Conversations }),
})),
prompts: [],
isError: false,
Expand Down

0 comments on commit 28ec9ac

Please sign in to comment.