mirror of
https://github.com/alkimake/paperclip.git
synced 2026-06-15 10:30:37 +09:00
Fix mine inbox keyboard selection
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
parent
44f052f4c5
commit
7d81e4cb2a
5 changed files with 53 additions and 12 deletions
|
|
@ -11,6 +11,7 @@ import {
|
|||
isMineInboxTab,
|
||||
loadLastInboxTab,
|
||||
RECENT_ISSUES_LIMIT,
|
||||
resolveInboxSelectionIndex,
|
||||
saveLastInboxTab,
|
||||
shouldShowInboxSection,
|
||||
} from "./inbox";
|
||||
|
|
@ -408,4 +409,11 @@ describe("inbox helpers", () => {
|
|||
expect(isMineInboxTab("unread")).toBe(false);
|
||||
expect(isMineInboxTab("all")).toBe(false);
|
||||
});
|
||||
|
||||
it("anchors Mine selection to the first available inbox row", () => {
|
||||
expect(resolveInboxSelectionIndex(-1, 3, true)).toBe(0);
|
||||
expect(resolveInboxSelectionIndex(-1, 3, false)).toBe(-1);
|
||||
expect(resolveInboxSelectionIndex(5, 3, true)).toBe(2);
|
||||
expect(resolveInboxSelectionIndex(1, 0, true)).toBe(-1);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -102,6 +102,16 @@ export function isMineInboxTab(tab: InboxTab): boolean {
|
|||
return tab === "mine";
|
||||
}
|
||||
|
||||
export function resolveInboxSelectionIndex(
|
||||
previousIndex: number,
|
||||
itemCount: number,
|
||||
canSelectItems: boolean,
|
||||
): number {
|
||||
if (itemCount === 0) return -1;
|
||||
if (previousIndex < 0) return canSelectItems ? 0 : -1;
|
||||
return Math.min(previousIndex, itemCount - 1);
|
||||
}
|
||||
|
||||
export function getLatestFailedRunsByAgent(runs: HeartbeatRun[]): HeartbeatRun[] {
|
||||
const sorted = [...runs].sort(
|
||||
(a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue