mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-06-12 17:34:27 +02:00
Fix environment sorting
This commit is contained in:
@@ -8,7 +8,7 @@ import { newStoreData } from './util';
|
|||||||
export const modelStoreDataAtom = atom(newStoreData());
|
export const modelStoreDataAtom = atom(newStoreData());
|
||||||
|
|
||||||
export const cookieJarsAtom = createOrderedModelAtom('cookie_jar', 'name', 'asc');
|
export const cookieJarsAtom = createOrderedModelAtom('cookie_jar', 'name', 'asc');
|
||||||
export const environmentsAtom = createOrderedModelAtom('environment', 'name', 'asc');
|
export const environmentsAtom = createOrderedModelAtom('environment', 'sortPriority', 'asc');
|
||||||
export const foldersAtom = createModelAtom('folder');
|
export const foldersAtom = createModelAtom('folder');
|
||||||
export const grpcConnectionsAtom = createOrderedModelAtom('grpc_connection', 'createdAt', 'desc');
|
export const grpcConnectionsAtom = createOrderedModelAtom('grpc_connection', 'createdAt', 'desc');
|
||||||
export const grpcEventsAtom = createOrderedModelAtom('grpc_event', 'createdAt', 'asc');
|
export const grpcEventsAtom = createOrderedModelAtom('grpc_event', 'createdAt', 'asc');
|
||||||
|
|||||||
@@ -331,12 +331,7 @@ const treeAtom = atom<TreeNode<TreeModel> | null>((get) => {
|
|||||||
|
|
||||||
const parent = root.children?.[0];
|
const parent = root.children?.[0];
|
||||||
if (baseEnvironments.length <= 1 && parent != null) {
|
if (baseEnvironments.length <= 1 && parent != null) {
|
||||||
const sortedEnvironments = [...subEnvironments].sort((a, b) => {
|
parent.children = subEnvironments.map((item) => ({
|
||||||
if (a.sortPriority === b.sortPriority) return a.updatedAt > b.updatedAt ? 1 : -1;
|
|
||||||
else return a.sortPriority - b.sortPriority;
|
|
||||||
});
|
|
||||||
|
|
||||||
parent.children = sortedEnvironments.map((item) => ({
|
|
||||||
item,
|
item,
|
||||||
parent,
|
parent,
|
||||||
depth: 1,
|
depth: 1,
|
||||||
|
|||||||
Reference in New Issue
Block a user