Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add empty folders to the export(issue#640) #692

Merged
merged 6 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions apps/chat/src/store/import-export/importExport.epics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {

import { combineEpics } from 'redux-observable';

import { filterOnlyMyEntities } from '@/src/utils/app/common';
import { combineEntities, filterOnlyMyEntities } from '@/src/utils/app/common';
import { BucketService } from '@/src/utils/app/data/bucket-service';
import { ConversationService } from '@/src/utils/app/data/conversation-service';
import { FileService } from '@/src/utils/app/data/file-service';
Expand Down Expand Up @@ -143,13 +143,17 @@ const exportConversationsEpic: AppEpic = (action$, state$) =>
new Set(conversationsListing.map((info) => info.folderId)),
);
//calculate all folders;
const folders = getFoldersFromPaths(
const foldersWithConversation = getFoldersFromPaths(
Array.from(
new Set(foldersIds.flatMap((id) => getAllPathsFromPath(id))),
),
FolderType.Chat,
);

const allFolders = ConversationsSelectors.selectFolders(state$.value);

const folders = combineEntities(foldersWithConversation, allFolders);

return forkJoin({
//get all conversations from api
conversations: zip(
Expand Down
6 changes: 3 additions & 3 deletions apps/chat/src/utils/app/import-export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,11 +346,12 @@ const getNewAttachmentFileFromUploaded = ({
if (!newAttachment.id) {
return;
}
const regExpForNewAttachmentId = /^imports\/[\w-]*\//;
const regExpForNewAttachmentId = /^imports\/[\w\s-]+\//;

const newAttachmentId = newAttachment.id.split(regExpForNewAttachmentId)[
attachmentIdIndex
];

return (
newAttachmentId === oldAttachmentId ||
oldAttachmentId.includes(newAttachmentId)
Expand All @@ -371,7 +372,6 @@ export const updateAttachment = ({
}

const attachmentIdIndex = 1;

const oldAttachmentId = getAttachmentId({
url: oldAttachmentUrl,
attachmentIdIndex,
Expand All @@ -390,7 +390,6 @@ export const updateAttachment = ({
const newAttachmentUrl =
oldAttachment.url &&
encodeURI(`${newAttachmentFile.absolutePath}/${newAttachmentFile.name}`);

const lastSlashIndex = oldAttachmentId.lastIndexOf('/');
const oldAttachmentNameInPath = oldAttachmentId.slice(lastSlashIndex + 1);

Expand All @@ -400,6 +399,7 @@ export const updateAttachment = ({

const updatedAttachment: Attachment = {
...oldAttachment,
type: newAttachmentFile.contentType ?? oldAttachment.type,
url: newAttachmentUrl,
reference_url: newReferenceUrl,
};
Expand Down
2 changes: 1 addition & 1 deletion apps/chat/src/utils/app/zip-import-export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ interface GetZippedFile {

const getAttachmentFromApi = async (file: DialFile) => {
const fileResult = await fetch(
`api/files/file/${constructPath(file.absolutePath, file.name)}`,
`api/${constructPath(file.absolutePath, file.name)}`,
);
return fileResult.blob();
};
Expand Down
Loading