diff --git a/pkg/interface/src/logic/lib/omnibox.js b/pkg/interface/src/logic/lib/omnibox.js index 4185d57b7..755e38653 100644 --- a/pkg/interface/src/logic/lib/omnibox.js +++ b/pkg/interface/src/logic/lib/omnibox.js @@ -1,4 +1,5 @@ import { cite } from '~/logic/lib/util'; +import { isChannelAdmin } from '~/logic/lib/group'; const indexes = new Map([ ['ships', []], @@ -27,13 +28,21 @@ const shipIndex = function(contacts) { return ships; }; -const commandIndex = function (currentGroup) { +const commandIndex = function (currentGroup, groups, associations) { // commands are special cased for default suite const commands = []; + const group = currentGroup ? groups[currentGroup] : null; + const association = currentGroup ? associations?.groups?.[currentGroup] : null; + const canAdd = + (group && association) + ? (association.metadata.vip === 'member-metadata' || isChannelAdmin(group, currentGroup)) + : !currentGroup; // home workspace or hasn't loaded const workspace = currentGroup || '/home'; commands.push(result(`Groups: Create`, `/~landscape/new`, 'Groups', null)); commands.push(result(`Groups: Join`, `/~landscape/join`, 'Groups', null)); - commands.push(result(`Channel: Create`, `/~landscape${workspace}/new`, 'Groups', null)); + if(canAdd) { + commands.push(result(`Channel: Create`, `/~landscape${workspace}/new`, 'Groups', null)); + } return commands; }; @@ -127,7 +136,7 @@ export default function index(contacts, associations, apps, currentGroup, groups }); }); - indexes.set('commands', commandIndex(currentGroup)); + indexes.set('commands', commandIndex(currentGroup, groups, associations)); indexes.set('subscriptions', subscriptions); indexes.set('groups', landscape); indexes.set('apps', appIndex(apps)); diff --git a/pkg/interface/src/logic/lib/util.ts b/pkg/interface/src/logic/lib/util.ts index c39f9607e..670c83d43 100644 --- a/pkg/interface/src/logic/lib/util.ts +++ b/pkg/interface/src/logic/lib/util.ts @@ -230,6 +230,11 @@ export function alphabeticalOrder(a: string, b: string) { return a.toLowerCase().localeCompare(b.toLowerCase()); } +export function lengthOrder(a: string, b: string) { + return b.length - a.length; + +} + // TODO: deprecated export function alphabetiseAssociations(associations: any) { const result = {}; diff --git a/pkg/interface/src/views/apps/chat/components/ChatMessage.tsx b/pkg/interface/src/views/apps/chat/components/ChatMessage.tsx index 4744bab36..d5f609124 100644 --- a/pkg/interface/src/views/apps/chat/components/ChatMessage.tsx +++ b/pkg/interface/src/views/apps/chat/components/ChatMessage.tsx @@ -496,7 +496,7 @@ export const MessageContent = ({ group={group} scrollWindow={scrollWindow} ship={content.mention} - contact={contacts?.[content.mention]} + contact={contacts?.[`~${content.mention}`]} /> ); } else { diff --git a/pkg/interface/src/views/apps/chat/components/content/text.js b/pkg/interface/src/views/apps/chat/components/content/text.js index 420b2453d..1edbd919d 100644 --- a/pkg/interface/src/views/apps/chat/components/content/text.js +++ b/pkg/interface/src/views/apps/chat/components/content/text.js @@ -85,8 +85,6 @@ export default function TextContent(props) { && (urbitOb.isValidPatp(group[2]) // valid patp? && (group[0] === content.text))) // entire message is room name? - console.log(isGroupLink); - if(isGroupLink) { const resource = `/ship/${content.text}`; return ( diff --git a/pkg/interface/src/views/apps/profile/components/Profile.tsx b/pkg/interface/src/views/apps/profile/components/Profile.tsx index 0676d7248..b156340b8 100644 --- a/pkg/interface/src/views/apps/profile/components/Profile.tsx +++ b/pkg/interface/src/views/apps/profile/components/Profile.tsx @@ -50,7 +50,7 @@ export function Profile(props: any) { return (
- { (contact?.groups || []).length > 0 && ( - - Pinned Groups - - { contact?.groups.map(g => ( - {}} - /> - ))} - - - )} { (ship === `~${window.ship}`) ? ( ) : null } + { (contact?.groups || []).length > 0 && ( + + Pinned Groups + + { contact?.groups.sort(lengthOrder).map(g => ( + {}} + /> + ))} + + + )} + { (nacked || (!isPublic && ship === `~${window.ship}`)) ? ( + + + {"<- Back"} + +