mirror of
https://github.com/wiseguru/ReWrite-Voice-Notes.git
synced 2026-07-22 07:49:19 +00:00
27 lines
869 B
TypeScript
27 lines
869 B
TypeScript
import { Platform } from 'obsidian';
|
|
import { ActiveProfileKind, EnvironmentProfile, GlobalSettings } from './types';
|
|
|
|
export function detectActiveProfileKind(settings: GlobalSettings): ActiveProfileKind {
|
|
switch (settings.activeProfileOverride) {
|
|
case 'desktop':
|
|
return 'desktop';
|
|
case 'mobile':
|
|
return 'mobile';
|
|
case 'auto':
|
|
default:
|
|
return Platform.isDesktop ? 'desktop' : 'mobile';
|
|
}
|
|
}
|
|
|
|
export function resolveActiveProfile(settings: GlobalSettings): {
|
|
kind: ActiveProfileKind;
|
|
profile: EnvironmentProfile;
|
|
} {
|
|
const kind = detectActiveProfileKind(settings);
|
|
const profile = kind === 'desktop' ? settings.desktopProfile : settings.mobileProfile;
|
|
return { kind, profile };
|
|
}
|
|
|
|
export function isMediaRecorderAvailable(): boolean {
|
|
return typeof MediaRecorder !== 'undefined' && typeof navigator !== 'undefined' && !!navigator.mediaDevices;
|
|
}
|