mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
implmenet custom sort to replace images adapter logic
This commit is contained in:
parent
719c066ac4
commit
7bbe236107
@ -15,7 +15,7 @@ import { zNodeStatus } from 'features/nodes/types/invocation';
|
|||||||
import { CANVAS_OUTPUT } from 'features/nodes/util/graph/constants';
|
import { CANVAS_OUTPUT } from 'features/nodes/util/graph/constants';
|
||||||
import { boardsApi } from 'services/api/endpoints/boards';
|
import { boardsApi } from 'services/api/endpoints/boards';
|
||||||
import { imagesApi } from 'services/api/endpoints/images';
|
import { imagesApi } from 'services/api/endpoints/images';
|
||||||
import { imagesAdapter } from 'services/api/util';
|
import { imageListDefaultSort, imagesAdapter } from 'services/api/util';
|
||||||
import { socketInvocationComplete } from 'services/events/actions';
|
import { socketInvocationComplete } from 'services/events/actions';
|
||||||
|
|
||||||
// These nodes output an image, but do not actually *save* an image, so we don't want to handle the gallery logic on them
|
// These nodes output an image, but do not actually *save* an image, so we don't want to handle the gallery logic on them
|
||||||
@ -68,7 +68,8 @@ export const addInvocationCompleteEventListener = (startAppListening: AppStartLi
|
|||||||
is_intermediate: false
|
is_intermediate: false
|
||||||
},
|
},
|
||||||
(draft) => {
|
(draft) => {
|
||||||
const updatedListLength = draft.items.unshift(imageDTO)
|
const updatedListLength = draft.items.unshift(imageDTO);
|
||||||
|
draft.items.sort(imageListDefaultSort())
|
||||||
if (updatedListLength > IMAGE_LIMIT) {
|
if (updatedListLength > IMAGE_LIMIT) {
|
||||||
draft.items.pop()
|
draft.items.pop()
|
||||||
}
|
}
|
||||||
|
@ -75,6 +75,19 @@ export const imagesAdapter = createEntityAdapter<ImageDTO, string>({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const imageListDefaultSort = () => {
|
||||||
|
return (a: ImageDTO, b: ImageDTO) => {
|
||||||
|
if (a.starred && !b.starred) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (!a.starred && b.starred) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return dateComparator(b.created_at, a.created_at);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Create selectors for the adapter.
|
// Create selectors for the adapter.
|
||||||
export const imagesSelectors = imagesAdapter.getSelectors(undefined, getSelectorsOptions);
|
export const imagesSelectors = imagesAdapter.getSelectors(undefined, getSelectorsOptions);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user