urbit/pkg/interface/src/logic/lib/workspace.ts

27 lines
585 B
TypeScript
Raw Normal View History

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':
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;
}