Make authorships show up again

It turns out our shiny new typed ES2015 `Map`s are not serializable to JSON. :(
Luckily, we only use strings as keys and can write a function that converts them to serializable objects!

Signed-off-by: David Mehren <dmehren1@gmail.com>
This commit is contained in:
David Mehren 2020-05-31 21:43:14 +02:00
parent 17f3dc1877
commit 908bf36fa0
No known key found for this signature in database
GPG key ID: 6017AF117F9756CB
2 changed files with 13 additions and 2 deletions

View file

@ -4,6 +4,16 @@ import { logger } from './logger'
import { Revision } from './models'
import { realtime } from './realtime'
/*
Converts a map from string to something into a plain JS object for transmitting via a websocket
*/
export function mapToObject<T> (map: Map<string, T>): object {
return Array.from(map).reduce((obj, [key, value]) => {
obj[key] = value
return obj
}, {})
}
export function getImageMimeType (imagePath: string): string | undefined {
const fileExtension = /[^.]+$/.exec(imagePath)
switch (fileExtension?.[0]) {