urbit/pkg/interface/src/logic/lib/workspace.ts
2021-04-21 17:22:08 -04:00

28 lines
611 B
TypeScript

import { Associations } from '@urbit/api';
import { Workspace } from '~/types';
export function getTitleFromWorkspace(
associations: Associations,
workspace: Workspace
) {
switch (workspace.type) {
case 'home':
return 'My Channels';
case 'messages':
return 'Messages';
case 'group':
const association = associations.groups[workspace.group];
return association?.metadata?.title || '';
}
}
export function getGroupFromWorkspace(
workspace: Workspace
): string | undefined {
if (workspace.type === 'group') {
return workspace.group;
}
return undefined;
}