mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-08 17:07:03 +03:00
Speedup list Selector a bit
This commit is contained in:
parent
d8b1e3432a
commit
ee5b30884f
1 changed files with 9 additions and 9 deletions
|
|
@ -31,7 +31,6 @@ export class Selector {
|
||||||
) {
|
) {
|
||||||
this.list = koList;
|
this.list = koList;
|
||||||
this.listChecked = koComputable(() => this.list.filter(item => item.checked())).extend({ rateLimit: 0 });
|
this.listChecked = koComputable(() => this.list.filter(item => item.checked())).extend({ rateLimit: 0 });
|
||||||
this.isListChecked = koComputable(() => 0 < this.listChecked().length);
|
|
||||||
|
|
||||||
this.focusedItem = koFocusedItem || ko.observable(null);
|
this.focusedItem = koFocusedItem || ko.observable(null);
|
||||||
this.selectedItem = koSelectedItem || ko.observable(null);
|
this.selectedItem = koSelectedItem || ko.observable(null);
|
||||||
|
|
@ -67,10 +66,7 @@ export class Selector {
|
||||||
|
|
||||||
this.selectedItem.subscribe((item) => {
|
this.selectedItem.subscribe((item) => {
|
||||||
if (item) {
|
if (item) {
|
||||||
if (this.isListChecked()) {
|
this.list.forEach(subItem => subItem.checked(false));
|
||||||
this.listChecked().forEach(subItem => subItem.checked(false));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.selectedItemUseCallback) {
|
if (this.selectedItemUseCallback) {
|
||||||
itemSelectedThrottle(item);
|
itemSelectedThrottle(item);
|
||||||
}
|
}
|
||||||
|
|
@ -218,11 +214,15 @@ export class Selector {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isListChecked() {
|
||||||
|
return this.list.find(item => item.checked());
|
||||||
|
}
|
||||||
|
|
||||||
itemSelected(item) {
|
itemSelected(item) {
|
||||||
if (this.isListChecked()) {
|
if (this.isListChecked()) {
|
||||||
item || (this.oCallbacks.ItemSelect || (()=>0))(null);
|
item || this.oCallbacks.ItemSelect?.(null);
|
||||||
} else if (item) {
|
} else if (item) {
|
||||||
(this.oCallbacks.ItemSelect || (()=>0))(item);
|
this.oCallbacks.ItemSelect?.(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -260,7 +260,7 @@ export class Selector {
|
||||||
const item = getItem(this.sItemSelector);
|
const item = getItem(this.sItemSelector);
|
||||||
if (item) {
|
if (item) {
|
||||||
this.focusedItem(item);
|
this.focusedItem(item);
|
||||||
(this.oCallbacks.MiddleClick || (()=>0))(item);
|
this.oCallbacks.MiddleClick?.(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -332,7 +332,7 @@ export class Selector {
|
||||||
} else if (++i < listLen) {
|
} else if (++i < listLen) {
|
||||||
result = list[i];
|
result = list[i];
|
||||||
}
|
}
|
||||||
result || (this.oCallbacks.UpOrDown || (()=>0))('ArrowUp' === sEventKey);
|
result || this.oCallbacks.UpOrDown?.('ArrowUp' === sEventKey);
|
||||||
} else if ('Home' === sEventKey) {
|
} else if ('Home' === sEventKey) {
|
||||||
result = list[0];
|
result = list[0];
|
||||||
} else if ('End' === sEventKey) {
|
} else if ('End' === sEventKey) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue