mirror of
https://github.com/urbit/shrub.git
synced 2024-12-20 01:01:37 +03:00
interface: screening DMs
This commit is contained in:
parent
7a4546c4a1
commit
bdf40b9deb
@ -218,6 +218,14 @@ export default class GraphApi extends BaseApi<StoreState> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
acceptDm(ship: Patp) {
|
||||||
|
return this.action('dm-hook', 'dm-hook-action', { "accept" : ship });
|
||||||
|
}
|
||||||
|
|
||||||
|
declineDm(ship: Patp) {
|
||||||
|
return this.action('dm-hook', 'dm-hook-action', { "decline" : ship });
|
||||||
|
}
|
||||||
|
|
||||||
addPost(ship: Patp, name: string, post: Post) {
|
addPost(ship: Patp, name: string, post: Post) {
|
||||||
const nodes = {};
|
const nodes = {};
|
||||||
nodes[post.index] = {
|
nodes[post.index] = {
|
||||||
|
@ -21,7 +21,38 @@ export const GraphReducer = (json) => {
|
|||||||
if(loose) {
|
if(loose) {
|
||||||
reduceState<GraphState, any>(useGraphState, loose, [addNodesLoose]);
|
reduceState<GraphState, any>(useGraphState, loose, [addNodesLoose]);
|
||||||
}
|
}
|
||||||
|
const dm = _.get(json, 'dm-hook-action', false);
|
||||||
|
if(dm) {
|
||||||
|
console.log(dm);
|
||||||
|
reduceState<GraphState, any>(useGraphState, dm, [
|
||||||
|
acceptOrRejectDm,
|
||||||
|
pendings,
|
||||||
|
setScreen
|
||||||
|
])
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
const acceptOrRejectDm = (json: any, state: GraphState): GraphState => {
|
||||||
|
const data = _.get(json, 'accept', _.get(json, 'decline', false));
|
||||||
|
if(data) {
|
||||||
|
state.pendingDms.delete(data)
|
||||||
|
}
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
const pendings = (json: any, state: GraphState): GraphState => {
|
||||||
|
const data = _.get(json, 'pendings', false);
|
||||||
|
if(data) {
|
||||||
|
state.pendingDms = new Set(data);
|
||||||
|
}
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
const setScreen = (json: any, state: GraphState): GraphState => {
|
||||||
|
if('screen' in json) {
|
||||||
|
state.screening = json.screen;
|
||||||
|
}
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
const addNodesLoose = (json: any, state: GraphState): GraphState => {
|
const addNodesLoose = (json: any, state: GraphState): GraphState => {
|
||||||
const data = _.get(json, 'add-nodes', false);
|
const data = _.get(json, 'add-nodes', false);
|
||||||
|
@ -14,6 +14,8 @@ export interface GraphState extends BaseState<GraphState> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
pendingIndices: Record<string, any>;
|
pendingIndices: Record<string, any>;
|
||||||
|
pendingDms: Set<string>;
|
||||||
|
screening: boolean;
|
||||||
graphTimesentMap: Record<string, any>;
|
graphTimesentMap: Record<string, any>;
|
||||||
// getKeys: () => Promise<void>;
|
// getKeys: () => Promise<void>;
|
||||||
// getTags: () => Promise<void>;
|
// getTags: () => Promise<void>;
|
||||||
@ -32,6 +34,8 @@ const useGraphState = createState<GraphState>('Graph', {
|
|||||||
looseNodes: {},
|
looseNodes: {},
|
||||||
pendingIndices: {},
|
pendingIndices: {},
|
||||||
graphTimesentMap: {},
|
graphTimesentMap: {},
|
||||||
|
pendingDms: new Set(),
|
||||||
|
screening: false,
|
||||||
// getKeys: async () => {
|
// getKeys: async () => {
|
||||||
// const api = useApi();
|
// const api = useApi();
|
||||||
// const keys = await api.scry({
|
// const keys = await api.scry({
|
||||||
|
@ -15,6 +15,7 @@ export default class GlobalSubscription extends BaseSubscription<StoreState> {
|
|||||||
this.subscribe('/groups', 'group-store');
|
this.subscribe('/groups', 'group-store');
|
||||||
this.clearQueue();
|
this.clearQueue();
|
||||||
|
|
||||||
|
this.subscribe('/updates', 'dm-hook');
|
||||||
this.subscribe('/all', 'contact-store');
|
this.subscribe('/all', 'contact-store');
|
||||||
this.subscribe('/all', 's3-store');
|
this.subscribe('/all', 's3-store');
|
||||||
this.subscribe('/keys', 'graph-store');
|
this.subscribe('/keys', 'graph-store');
|
||||||
|
Loading…
Reference in New Issue
Block a user