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

28 lines
611 B
TypeScript
Raw Normal View History

import { Associations } from '@urbit/api';
import { Workspace } from '~/types';
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;
}