mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-01 20:04:09 +03:00
parent
5602a19cbd
commit
1704fe5039
@ -405,26 +405,17 @@ export const addNodes = (json, state) => {
|
||||
const removePosts = (json, state: GraphState): GraphState => {
|
||||
const _remove = (graph, index) => {
|
||||
const child = graph.get(index[0]);
|
||||
if(!child) {
|
||||
return graph;
|
||||
}
|
||||
if (index.length === 1) {
|
||||
if (child) {
|
||||
return graph.set(index[0], {
|
||||
post: child.post.hash || '',
|
||||
children: child.children
|
||||
});
|
||||
}
|
||||
return graph.set(index[0], {
|
||||
post: child.post.hash || '',
|
||||
children: child.children
|
||||
});
|
||||
} else {
|
||||
if (child) {
|
||||
_remove(child.children, index.slice(1));
|
||||
return graph.set(index[0], child);
|
||||
} else {
|
||||
const child = graph.get(index[0]);
|
||||
if (child) {
|
||||
return graph.set(index[0], produce((draft: any) => {
|
||||
draft.children = _remove(draft.children, index.slice(1));
|
||||
}));
|
||||
}
|
||||
return graph;
|
||||
}
|
||||
const node = { ...child, children: _remove(child.children, index.slice(1)) };
|
||||
return graph.set(index[0], node);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { cite, Content, Post } from '@urbit/api';
|
||||
import { cite, Content, Post, removeDmMessage } from '@urbit/api';
|
||||
import React, { useCallback, useEffect } from 'react';
|
||||
import _ from 'lodash';
|
||||
import bigInt from 'big-integer';
|
||||
@ -11,6 +11,7 @@ import useHarkState, { useHarkDm } from '~/logic/state/hark';
|
||||
import useSettingsState, { selectCalmState } from '~/logic/state/settings';
|
||||
import { ChatPane } from './components/ChatPane';
|
||||
import shallow from 'zustand/shallow';
|
||||
import airlock from '~/logic/api';
|
||||
|
||||
interface DmResourceProps {
|
||||
ship: string;
|
||||
@ -121,6 +122,9 @@ export function DmResource(props: DmResourceProps) {
|
||||
[ship, addDmMessage]
|
||||
);
|
||||
|
||||
const onDelete = useCallback((msg: Post) => {
|
||||
airlock.poke(removeDmMessage(`~${window.ship}`, msg.index));
|
||||
}, []);
|
||||
return (
|
||||
<Col width="100%" height="100%" overflow="hidden">
|
||||
<Row
|
||||
@ -169,6 +173,7 @@ export function DmResource(props: DmResourceProps) {
|
||||
onReply={quoteReply}
|
||||
fetchMessages={fetchMessages}
|
||||
dismissUnread={dismissUnread}
|
||||
onDelete={onDelete}
|
||||
getPermalink={() => undefined}
|
||||
isAdmin={false}
|
||||
onSubmit={onSubmit}
|
||||
|
@ -336,6 +336,26 @@ export const removePosts = (
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Remove a DM message from our inbox
|
||||
*
|
||||
* @remarks
|
||||
* This does not remove the message from the recipients inbox
|
||||
*/
|
||||
export const removeDmMessage = (
|
||||
our: Patp,
|
||||
index: string
|
||||
): Poke<any> => ({
|
||||
app: 'graph-store',
|
||||
mark: `graph-update-${GRAPH_UPDATE_VERSION}`,
|
||||
json: {
|
||||
'remove-posts': {
|
||||
resource: { ship: our, name: 'dm-inbox' },
|
||||
indices: [index]
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Send a DM to a ship
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user