1import create from 'zustand';
2import { L2Point, PendingTransaction } from '@urbit/roller-api';
4import { HOUR, isL2, isL2Spawn } from 'lib/utils/roller';
5import { Invite } from 'lib/types/Invite';
7export interface RollerStore {
10 pendingTransactions: PendingTransaction[];
11 currentPoint: L2Point | null;
13 currentL2Spawn: boolean;
14 invitePoints: number[];
16 recentlyCompleted: number;
17 inviteGeneratingNum: number;
18 setNextBatchTime: (nextBatchTime: number) => void;
19 setNextRoll: (nextRoll: string) => void;
20 setPendingTransactions: (pendingTransactions: PendingTransaction[]) => void;
21 setCurrentPoint: (currentPoint: L2Point) => void;
22 setInvitePoints: (points: number[]) => void;
23 setInvites: (invites: Invite[]) => void;
24 setInviteGeneratingNum: (numGenerating: number) => void;
27export const useRollerStore = create<RollerStore>(set => ({
28 nextBatchTime: new Date().getTime() + HOUR,
29 nextRoll: '0h 00m 00s',
30 pendingTransactions: [],
33 currentL2Spawn: false,
37 inviteGeneratingNum: 0,
38 setNextBatchTime: (nextBatchTime: number) => set(() => ({ nextBatchTime })),
39 setNextRoll: (nextRoll: string) => set(() => ({ nextRoll })),
40 setPendingTransactions: (pendingTransactions: PendingTransaction[]) =>
42 const oldPending = state.pendingTransactions.length;
43 if (oldPending > 0 && pendingTransactions.length === 0) {
47 recentlyCompleted: oldPending,
50 return { ...state, pendingTransactions };
52 setCurrentPoint: (currentPoint: L2Point) =>
55 currentL2: isL2(currentPoint?.dominion),
56 currentL2Spawn: isL2Spawn(currentPoint?.dominion),
58 setInvitePoints: (invitePoints: number[]) => set(() => ({ invitePoints })),
59 setInvites: (invites: Invite[]) => set(() => ({ invites })),
60 setInviteGeneratingNum: (inviteGeneratingNum: number) =>
61 set(() => ({ inviteGeneratingNum })),
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list