mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-23 06:42:09 +03:00
28 lines
611 B
TypeScript
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;
|
|
}
|