mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-11-28 11:40:11 +03:00
parent
2382130e39
commit
7de7917294
@ -19,7 +19,6 @@ import GroupSearch from '~/views/components/GroupSearch';
|
||||
import { ImageInput } from '~/views/components/ImageInput';
|
||||
import {
|
||||
ProfileControls, ProfileHeader,
|
||||
|
||||
ProfileImages, ProfileStatus
|
||||
} from './Profile';
|
||||
import airlock from '~/logic/api';
|
||||
@ -96,7 +95,7 @@ export function EditProfile(props: any): ReactElement {
|
||||
const newValue = key !== 'color' ? values[key] : uxToHex(values[key]);
|
||||
if (newValue !== contact[key]) {
|
||||
if (key === 'isPublic') {
|
||||
airlock.poke(setPublic(true));
|
||||
airlock.poke(setPublic(newValue));
|
||||
return;
|
||||
} else if (key === 'groups') {
|
||||
const toRemove: string[] = _.difference(
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
import { Path, Patp, Poke, resourceAsPath, Scry } from "../lib";
|
||||
import { Patp, Poke, Scry } from '../lib';
|
||||
import {
|
||||
Contact,
|
||||
ContactUpdateAdd,
|
||||
@ -10,36 +10,36 @@ import {
|
||||
ContactUpdate,
|
||||
ContactUpdateAllowShips,
|
||||
ContactUpdateAllowGroup,
|
||||
ContactUpdateSetPublic,
|
||||
} from "./types";
|
||||
ContactUpdateSetPublic
|
||||
} from './types';
|
||||
|
||||
export const CONTACT_UPDATE_VERSION: number = 0;
|
||||
export const CONTACT_UPDATE_VERSION = 0;
|
||||
|
||||
const storeAction = <T extends ContactUpdate>(data: T, version: number = CONTACT_UPDATE_VERSION): Poke<T> => ({
|
||||
app: "contact-store",
|
||||
app: 'contact-store',
|
||||
mark: `contact-update-${version}`,
|
||||
json: data,
|
||||
json: data
|
||||
});
|
||||
|
||||
export { storeAction as contactStoreAction };
|
||||
|
||||
export const addContact = (ship: Patp, contact: Contact): Poke<ContactUpdateAdd> => {
|
||||
contact["last-updated"] = Date.now();
|
||||
contact['last-updated'] = Date.now();
|
||||
|
||||
return storeAction({
|
||||
add: { ship, contact },
|
||||
add: { ship, contact }
|
||||
});
|
||||
};
|
||||
|
||||
export const removeContact = (ship: Patp): Poke<ContactUpdateRemove> =>
|
||||
storeAction({
|
||||
remove: { ship },
|
||||
remove: { ship }
|
||||
});
|
||||
|
||||
export const share = (recipient: Patp, version: number = CONTACT_UPDATE_VERSION): Poke<ContactShare> => ({
|
||||
app: "contact-push-hook",
|
||||
mark: "contact-share",
|
||||
json: { share: recipient },
|
||||
app: 'contact-push-hook',
|
||||
mark: 'contact-share',
|
||||
json: { share: recipient }
|
||||
});
|
||||
|
||||
export const editContact = (
|
||||
@ -49,9 +49,9 @@ export const editContact = (
|
||||
storeAction({
|
||||
edit: {
|
||||
ship,
|
||||
"edit-field": editField,
|
||||
timestamp: Date.now(),
|
||||
},
|
||||
'edit-field': editField,
|
||||
timestamp: Date.now()
|
||||
}
|
||||
});
|
||||
|
||||
export const allowShips = (
|
||||
@ -67,7 +67,7 @@ export const allowGroup = (
|
||||
name: string
|
||||
): Poke<ContactUpdateAllowGroup> => storeAction({
|
||||
allow: {
|
||||
group: resourceAsPath({ ship, name })
|
||||
group: { ship, name }
|
||||
}
|
||||
});
|
||||
|
||||
@ -77,7 +77,7 @@ export const setPublic = (
|
||||
return storeAction({
|
||||
'set-public': setPublic
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export const retrieve = (
|
||||
ship: string
|
||||
@ -93,7 +93,7 @@ export const retrieve = (
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
export const fetchIsAllowed = (
|
||||
entity: string,
|
||||
@ -105,5 +105,5 @@ export const fetchIsAllowed = (
|
||||
return {
|
||||
app: 'contact-store',
|
||||
path: `/is-allowed/${entity}/${name}/${ship}/${isPersonal}`
|
||||
}
|
||||
};
|
||||
};
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { Path, Patp } from "../lib";
|
||||
import { Resource } from "../groups";
|
||||
import { Path, Patp } from '../lib';
|
||||
import { Resource } from '../groups';
|
||||
|
||||
export type ContactUpdate =
|
||||
| ContactUpdateAdd
|
||||
@ -26,7 +26,7 @@ export interface ContactUpdateRemove {
|
||||
export interface ContactUpdateEdit {
|
||||
edit: {
|
||||
ship: Patp;
|
||||
"edit-field": ContactEditField;
|
||||
'edit-field': ContactEditField;
|
||||
timestamp: number;
|
||||
};
|
||||
}
|
||||
@ -39,7 +39,7 @@ export interface ContactUpdateAllowShips {
|
||||
|
||||
export interface ContactUpdateAllowGroup {
|
||||
allow: {
|
||||
group: Path;
|
||||
group: Resource;
|
||||
}
|
||||
}
|
||||
|
||||
@ -74,7 +74,7 @@ export interface Contact {
|
||||
|
||||
type ContactKeys = keyof Contact;
|
||||
|
||||
export type ContactEditFieldPrim = Exclude<ContactKeys, "groups" | "last-updated">;
|
||||
export type ContactEditFieldPrim = Exclude<ContactKeys, 'groups' | 'last-updated'>;
|
||||
|
||||
export type ContactEditField = Partial<Pick<Contact, ContactEditFieldPrim>> & {
|
||||
'add-group'?: Resource;
|
||||
|
Loading…
Reference in New Issue
Block a user