fix open uncategorized section
This commit is contained in:
parent
2a93b0a873
commit
5e56485a8d
|
@ -11,6 +11,7 @@ import ShortcutButton from './ShortcutButton';
|
|||
import DeleteOutline from '@mui/icons-material/DeleteOutline';
|
||||
import ArchiveOutlined from '@mui/icons-material/ArchiveOutlined';
|
||||
import CategoryIcon from '@mui/icons-material/Category';
|
||||
import { getUncategorizedCollection } from 'services/collectionService';
|
||||
interface Iprops {
|
||||
closeSidebar: () => void;
|
||||
collectionSummaries: CollectionSummaries;
|
||||
|
@ -22,8 +23,9 @@ export default function ShortcutSection({
|
|||
}: Iprops) {
|
||||
const galleryContext = useContext(GalleryContext);
|
||||
|
||||
const openUncategorizedSection = () => {
|
||||
galleryContext.setActiveCollection(UNCATEGORIZED_SECTION);
|
||||
const openUncategorizedSection = async () => {
|
||||
const uncategorisedCollection = await getUncategorizedCollection();
|
||||
galleryContext.setActiveCollection(uncategorisedCollection.id);
|
||||
closeSidebar();
|
||||
};
|
||||
|
||||
|
|
|
@ -37,7 +37,6 @@ import {
|
|||
COLLECTION_SORT_ORDER,
|
||||
ALL_SECTION,
|
||||
CollectionSummaryType,
|
||||
UNCATEGORIZED_SECTION,
|
||||
UNCATEGORIZED_COLLECTION_NAME,
|
||||
FAVORITE_COLLECTION_NAME,
|
||||
} from 'constants/collection';
|
||||
|
@ -850,14 +849,6 @@ export function getCollectionSummaries(
|
|||
)
|
||||
);
|
||||
|
||||
collectionSummaries.set(
|
||||
UNCATEGORIZED_SECTION,
|
||||
getUncategorizedCollectionSummaries(
|
||||
collectionFilesCount,
|
||||
collectionLatestFiles
|
||||
)
|
||||
);
|
||||
|
||||
return collectionSummaries;
|
||||
}
|
||||
|
||||
|
@ -934,22 +925,7 @@ function getTrashedCollectionSummaries(
|
|||
};
|
||||
}
|
||||
|
||||
function getUncategorizedCollectionSummaries(
|
||||
collectionFilesCount: CollectionFilesCount,
|
||||
collectionsLatestFile: CollectionLatestFiles
|
||||
): CollectionSummary {
|
||||
return {
|
||||
id: UNCATEGORIZED_SECTION,
|
||||
name: constants.UNCATEGORIZED,
|
||||
type: CollectionSummaryType.uncategorized,
|
||||
latestFile: collectionsLatestFile.get(UNCATEGORIZED_SECTION),
|
||||
fileCount: collectionFilesCount.get(UNCATEGORIZED_SECTION) ?? 0,
|
||||
updationTime: collectionsLatestFile.get(UNCATEGORIZED_SECTION)
|
||||
?.updationTime,
|
||||
};
|
||||
}
|
||||
|
||||
async function getUncategorizedCollection(): Promise<Collection> {
|
||||
export async function getUncategorizedCollection(): Promise<Collection> {
|
||||
const collections = await getLocalCollections();
|
||||
let uncategorizedCollection = collections.find(
|
||||
(collection) => collection.type === CollectionType.uncategorized
|
||||
|
|
Loading…
Reference in a new issue