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 DeleteOutline from '@mui/icons-material/DeleteOutline';
|
||||||
import ArchiveOutlined from '@mui/icons-material/ArchiveOutlined';
|
import ArchiveOutlined from '@mui/icons-material/ArchiveOutlined';
|
||||||
import CategoryIcon from '@mui/icons-material/Category';
|
import CategoryIcon from '@mui/icons-material/Category';
|
||||||
|
import { getUncategorizedCollection } from 'services/collectionService';
|
||||||
interface Iprops {
|
interface Iprops {
|
||||||
closeSidebar: () => void;
|
closeSidebar: () => void;
|
||||||
collectionSummaries: CollectionSummaries;
|
collectionSummaries: CollectionSummaries;
|
||||||
|
@ -22,8 +23,9 @@ export default function ShortcutSection({
|
||||||
}: Iprops) {
|
}: Iprops) {
|
||||||
const galleryContext = useContext(GalleryContext);
|
const galleryContext = useContext(GalleryContext);
|
||||||
|
|
||||||
const openUncategorizedSection = () => {
|
const openUncategorizedSection = async () => {
|
||||||
galleryContext.setActiveCollection(UNCATEGORIZED_SECTION);
|
const uncategorisedCollection = await getUncategorizedCollection();
|
||||||
|
galleryContext.setActiveCollection(uncategorisedCollection.id);
|
||||||
closeSidebar();
|
closeSidebar();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,6 @@ import {
|
||||||
COLLECTION_SORT_ORDER,
|
COLLECTION_SORT_ORDER,
|
||||||
ALL_SECTION,
|
ALL_SECTION,
|
||||||
CollectionSummaryType,
|
CollectionSummaryType,
|
||||||
UNCATEGORIZED_SECTION,
|
|
||||||
UNCATEGORIZED_COLLECTION_NAME,
|
UNCATEGORIZED_COLLECTION_NAME,
|
||||||
FAVORITE_COLLECTION_NAME,
|
FAVORITE_COLLECTION_NAME,
|
||||||
} from 'constants/collection';
|
} from 'constants/collection';
|
||||||
|
@ -850,14 +849,6 @@ export function getCollectionSummaries(
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
collectionSummaries.set(
|
|
||||||
UNCATEGORIZED_SECTION,
|
|
||||||
getUncategorizedCollectionSummaries(
|
|
||||||
collectionFilesCount,
|
|
||||||
collectionLatestFiles
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
return collectionSummaries;
|
return collectionSummaries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -934,22 +925,7 @@ function getTrashedCollectionSummaries(
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function getUncategorizedCollectionSummaries(
|
export async function getUncategorizedCollection(): Promise<Collection> {
|
||||||
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> {
|
|
||||||
const collections = await getLocalCollections();
|
const collections = await getLocalCollections();
|
||||||
let uncategorizedCollection = collections.find(
|
let uncategorizedCollection = collections.find(
|
||||||
(collection) => collection.type === CollectionType.uncategorized
|
(collection) => collection.type === CollectionType.uncategorized
|
||||||
|
|
Loading…
Reference in a new issue