2021-02-15 01:11:27 +03:00
|
|
|
import { Associations, Workspace } from '@urbit/api';
|
2020-09-25 03:42:56 +03:00
|
|
|
|
|
|
|
export function getTitleFromWorkspace(
|
|
|
|
associations: Associations,
|
|
|
|
workspace: Workspace
|
|
|
|
) {
|
|
|
|
switch (workspace.type) {
|
2021-02-15 01:11:27 +03:00
|
|
|
case 'home':
|
|
|
|
return 'My Channels';
|
|
|
|
case 'messages':
|
|
|
|
return 'Messages';
|
|
|
|
case 'group':
|
2021-01-30 01:28:48 +03:00
|
|
|
const association = associations.groups[workspace.group];
|
2021-02-15 01:11:27 +03:00
|
|
|
return association?.metadata?.title || '';
|
2020-09-25 03:42:56 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function getGroupFromWorkspace(
|
|
|
|
workspace: Workspace
|
|
|
|
): string | undefined {
|
2021-02-15 01:11:27 +03:00
|
|
|
if (workspace.type === 'group') {
|
2020-09-25 03:42:56 +03:00
|
|
|
return workspace.group;
|
|
|
|
}
|
|
|
|
|
|
|
|
return undefined;
|
|
|
|
}
|