Merge pull request #4679 from urbit/lf/mor-nxt-usp

next-userspace grabbag vol. 2
This commit is contained in:
matildepark 2021-03-29 14:29:21 -04:00 committed by GitHub
commit 2f6a33094b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 80 additions and 15 deletions

View File

@ -193,6 +193,11 @@
(~(put by joining) rid [%.n now.bowl ship %start])
=. jn-core
(jn-abed rid)
=. jn-core
%- emit
%+ fact:io
group-view-update+!>([%started rid (~(got by joining) rid)])
~[/all]
?< ~|("already joined {<rid>}" (has-joined rid))
=. jn-core
%- emit

View File

@ -54,9 +54,17 @@
?- -.upd
%initial (initial +.upd)
%progress (progress +.upd)
%started (started +.upd)
%hide s+(enjs-path:resource +.upd)
==
::
++ started
|= [rid=resource req=^request]
%- pairs
:~ resource+s+(enjs-path:resource rid)
request+(request req)
==
::
++ progress
|= [rid=resource prog=^progress]
%- pairs

View File

@ -12,10 +12,11 @@
++ graph-permissions-remove
|= vip=vip-metadata:met
[%yes %self %self]
:: +notification-kind: no notifications for now
:: +notification-kind: don't track unreads, notify on replies
::
++ notification-kind
=/ len (lent index.p.i)
?: =(1 len) ~
`[%post [(dec len) len] %none %children]
::
++ transform-add-nodes

View File

@ -31,6 +31,7 @@
::
+$ update
$% [%initial initial=(map resource request)]
[%started =resource =request]
[%progress =resource =progress]
[%hide =resource]
==

View File

@ -308,10 +308,8 @@ export default class GraphApi extends BaseApi<StoreState> {
}
getGraph(ship: string, resource: string) {
console.log(ship, resource);
return this.scry<any>('graph-store', `/graph/${ship}/${resource}`)
.then((graph) => {
console.log(graph);
this.store.handleEvent({
data: graph
});

View File

@ -11,12 +11,22 @@ const initial = (json: any, state: GroupState): GroupState => {
return state;
};
const started = (json: any, state: GroupState): GroupState => {
const data = json.started;
if(data) {
const { resource, request } = data;
state.pendingJoin[resource] = request;
}
return state;
}
const progress = (json: any, state: GroupState): GroupState => {
const data = json.progress;
if(data) {
const { progress, resource } = data;
state.pendingJoin[resource].progress = progress;
if(progress === 'done') {
setTimeout(() => {
delete state.pendingJoin[resource];
}, 10000);
@ -40,6 +50,7 @@ export const GroupViewReducer = (json: any) => {
reduceState<GroupState, GroupUpdate>(useGroupState, data, [
progress,
hide,
started,
initial
]);
}

View File

@ -144,7 +144,6 @@ export default class ChatEditor extends Component {
messageChange(editor, data, value) {
if(value.endsWith('/')) {
console.log('showing');
editor.showHint(['test', 'foo']);
}
if (this.state.message !== '' && value == '') {

View File

@ -78,11 +78,12 @@ export const LinkItem = (props: LinkItemProps): ReactElement => {
const { doCopy: doCopyLink, copyDisplay: locationText } = useCopy(
contents[1].url,
'Copy Link Location'
'Copy block source'
);
const { doCopy: doCopyNode, copyDisplay: nodeText } = useCopy(
permalink,
'Copy Node Permalink'
'Copy reference'
);
const deleteLink = () => {

View File

@ -89,6 +89,7 @@ export function Invites(props: InvitesProps): ReactElement {
invite={invite}
app={app}
uid={uid}
join={join}
resource={resource}
/>
);

View File

@ -14,6 +14,7 @@ import GroupSearch from '~/views/components/GroupSearch';
import { useTutorialModal } from '~/views/components/useTutorialModal';
import useHarkState from '~/logic/state/hark';
import useMetadataState from '~/logic/state/metadata';
import useGroupState from '~/logic/state/group';
const baseUrl = '/~notifications';
@ -41,6 +42,7 @@ export default function NotificationsScreen(props: any): ReactElement {
const [filter, setFilter] = useState<NotificationFilter>({ groups: [] });
const associations = useMetadataState(state => state.associations);
const pendingJoin = useGroupState(s => s.pendingJoin);
const onSubmit = async ({ groups } : NotificationFilter) => {
setFilter({ groups });
};
@ -128,7 +130,11 @@ export default function NotificationsScreen(props: any): ReactElement {
</Dropdown>
</Row>
</Row>
{!view && <Inbox {...props} filter={filter.groups} />}
{!view && <Inbox
pendingJoin={pendingJoin}
{...props}
filter={filter.groups}
/>}
</Col>
</Body>
</>

View File

@ -1,11 +1,12 @@
import React from "react";
import { Anchor, Icon, Box, Row, Col, Text } from "@tlon/indigo-react";
import ChatMessage from "../chat/components/ChatMessage";
import { Association, GraphNode } from "@urbit/api";
import { Association, GraphNode, Post, Group } from "@urbit/api";
import { useGroupForAssoc } from "~/logic/state/group";
import { MentionText } from "~/views/components/MentionText";
import Author from "~/views/components/Author";
import { NoteContent } from "../publish/components/Note";
import { PostContent } from "~/views/landscape/components/Home/Post/PostContent";
import bigInt from "big-integer";
import { getSnippet } from "~/logic/lib/publish";
import { NotePreviewContent } from "../publish/components/NotePreview";
@ -124,6 +125,34 @@ function TranscludedPublishNode(props: {
}
}
export function TranscludedPost(props: {
post: Post;
api: GlobalApi;
transcluded: number;
group: Group;
}) {
const { transcluded, post, group, api } = props;
return (
<Col>
<Author
p="2"
showImage
ship={post.author}
date={post?.["time-sent"]}
group={group}
/>
<Box p="2">
<MentionText
api={api}
transcluded={transcluded}
content={post.contents}
group={group}
/>
</Box>
</Col>
);
}
export function TranscludedNode(props: {
assoc: Association;
node: GraphNode;
@ -158,6 +187,15 @@ export function TranscludedNode(props: {
return <TranscludedPublishNode {...props} />;
case "link":
return <TranscludedLinkNode {...props} />;
case "post":
return (
<TranscludedPost
api={props.api}
post={node.post}
group={group}
transcluded={transcluded}
/>)
;
default:
return null;
}

View File

@ -29,13 +29,11 @@ export function PermalinkRoutes(props: {}) {
path="/perma/group/:ship/:name"
render={({ match, history, location }) => {
const { ship, name } = match.params as ResourceRouteProps;
console.log(ship);
const { url } = match;
const path = `/ship/${ship}/${name}`;
const group = groups[path];
if(!group) {
if (Object.keys(groups).length > 0) {
console.log(groups);
const redir = location.pathname;
const to = toQuery({ redir }, `/~landscape/join/${ship}/${name}`);
return <Redirect to={to} />;
@ -60,7 +58,6 @@ function FallbackRoutes(props: { query: URLSearchParams }) {
return <Redirect to={{ pathname: url }} />;
}
console.log('aaaaa');
return <Redirect to="/~404" />;
}
@ -71,7 +68,6 @@ function GroupRoutes(props: { group: string; url: string }) {
const graphKeys = useGraphState(s => s.graphKeys);
const { toQuery } = useQuery();
const groupUrl = `/~landscape${group}`;
console.log(group);
return (
<Switch>
@ -85,7 +81,6 @@ function GroupRoutes(props: { group: string; url: string }) {
if(!association) {
return null;
}
console.log(graphKeys);
if(!graphKeys.has(`${ship.slice(1)}/${name}`)) {
if(graphKeys.size > 0) {
return <Redirect

View File

@ -108,7 +108,7 @@ export function InviteItem(props: InviteItemProps) {
}
}, [invite]);
if(status?.hidden) {
if(pendingJoin?.hidden) {
return null;
}
@ -119,7 +119,7 @@ export function InviteItem(props: InviteItemProps) {
api={api}
preview={preview}
invite={invite}
status={status}
status={pendingJoin}
{...handlers}
/>
);

View File

@ -16,6 +16,7 @@ export function PostContent(props) {
contacts={contacts}
content={post.contents}
api={api}
transcluded={0}
/>
</Col>
);