Merge pull request #3649 from urbit/mp/publish/regressions

publish: crashes and regressions
This commit is contained in:
matildepark 2020-10-06 14:31:49 -04:00 committed by GitHub
commit 704b52adad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 24 additions and 5 deletions

View File

@ -187,8 +187,18 @@ export default class PublishApi extends BaseApi {
});
}
readNote(who: PatpNoSig, book: string, note: string) {
return this.publishAction({
read: {
who,
book,
note
}
});
}
updateComment(who: PatpNoSig, book: string, note: string, comment: Path, body: string) {
return this.publishAction({
return this.publishAction({
'edit-comment': {
who,
book,

View File

@ -29,6 +29,7 @@ export function PublishResource(props: PublishResourceProps) {
contacts={props.contacts}
groups={props.groups}
notebook={notebook}
associations={props.associations}
notebookContacts={notebookContacts}
rootUrl={baseUrl}
baseUrl={`${baseUrl}/resource/publish/${ship}/${book}`}

View File

@ -18,7 +18,10 @@ interface AuthorProps {
export function Author(props: AuthorProps) {
const { contacts, ship = '', date, showImage } = props;
const noSig = ship.slice(1);
const contact = noSig in contacts ? contacts[noSig] : null;
let contact = null;
if (contacts) {
contact = noSig in contacts ? contacts[noSig] : null;
}
const color = contact?.color ? `#${uxToHex(contact?.color)}` : "#000000";
const showAvatar = !props.hideAvatars && contact?.avatar;
const showNickname = !props.hideNicknames && contact?.nickname;

View File

@ -33,6 +33,7 @@ export function Note(props: NoteProps & RouteComponentProps) {
const [deleting, setDeleting] = useState(false);
const { notebook, note, contacts, ship, book, noteId, api } = props;
useEffect(() => {
api.publish.readNote(ship.slice(1), book, noteId);
api.publish.fetchNote(ship, book, noteId);
}, [ship, book, noteId]);

View File

@ -70,7 +70,7 @@ export class Notebook extends PureComponent<
const relativePath = (p: string) => this.props.baseUrl + p;
const contact = notebookContacts[ship];
const contact = notebookContacts?.[ship];
const role = group ? roleForShip(group, window.ship) : undefined;
const isOwn = `~${window.ship}` === ship;
const isAdmin = role === "admin" || isOwn;

View File

@ -28,7 +28,7 @@ export function NotebookPosts(props: NotebookPostsProps) {
host={props.host}
book={props.book}
note={note}
contact={props.contacts[note.author.substr(1)]}
contact={props?.contacts?.[note.author.substr(1)]}
hideNicknames={props.hideNicknames}
baseUrl={props.baseUrl}
/>

View File

@ -118,7 +118,10 @@ export function DropdownSearch<C>(props: DropdownSearchProps<C>) {
const dropdown = useMemo(() => {
const first = props.isExact(query);
const opts = first ? [first, ...options] : options;
let opts = options;
if (first) {
opts = options.includes(first) ? opts : [first, ...options];
}
return _.take(opts, 5).map((o, idx) =>
props.renderCandidate(
o,

View File

@ -87,6 +87,7 @@ export function GroupSearch(props: InviteSearchProps) {
id={props.id}
caption={props.caption}
candidates={groups}
isExact={() => undefined}
renderCandidate={renderCandidate}
disabled={value && value.length !== 0}
search={(s: string, a: Association) =>