1import type { Apps } from 'types/store';
2import store from 'stores/store';
3import { api } from 'lib/api';
4import { normalizeId } from 'lib/id';
6export function getProvidedApps(patp: string): Promise<any> {
7 return api.scry<any>({ app: 'treaty', path: `/treaties/${patp}` });
10export function getKnownApps(): Promise<any> {
11 return api.scry<any>({ app: 'treaty', path: `/allies` }).then(processAllies);
14export function getApp(ship: string, desk: string): Promise<any> {
15 return api.scry<any>({ app: 'treaty', path: `/treaty/${normalizeId(ship)}/${desk}` });
18// @param path - ship/desk e.g. ~mister-dister-dozzod-dozzod/webterm
19export function getAppByPath(path: string): Promise<any> {
20 return api.scry<any>({ app: 'treaty', path: `/treaty/${path}` });
23export function getInstalledApps(): Promise<any> {
24 return api.scry<any>({ app: 'docket', path: `/charges` });
27export async function sendAllyUpdate(cmd: string, ship: string) {
28 let result = await api.poke({
30 mark: 'ally-update-0',
31 json: { [cmd]: normalizeId(ship) },
33 // store.refreshKnownApps();
37export function addAlly(patp: string) {
38 return sendAllyUpdate('add', patp);
41export function delAlly(patp: string) {
42 return sendAllyUpdate('del', patp);
45export async function addAllies(ships: string[]) {
46 let results = await Promise.allSettled(ships.map((ship: string) => {
47 return addAlly(normalizeId(ship));
49 results = results.filter(r => r.status === 'fulfilled').map((r) => {
50 return (r as PromiseFulfilledResult<any>).value;
52 store.refreshKnownApps();
56export async function delAllies(ships: string[], retry: number = 0) {
57 let results = await Promise.allSettled(ships.map((ship: string) => {
58 return delAlly(normalizeId(ship));
60 results = results.filter(r => r.status === 'fulfilled').map((r) => {
61 return (r as PromiseFulfilledResult<any>).value;
63 store.refreshKnownApps();
67export function processAllies(rawPals: any): Apps {
68 let allies = rawPals.ini;
69 let paths = Object.values(allies).flat() as string[];
70 let set = new Set(paths);
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