refactor: use enumeration for the type of an origin

This commit is contained in:
Jovan Krunić
2019-01-04 09:58:52 +01:00
parent a4f3fab033
commit e0e0a09c7c
2 changed files with 13 additions and 4 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 StApps
* Copyright (C) 2018, 2019 StApps
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3.
@@ -96,7 +96,13 @@ export interface SCThing {
url?: string;
}
export type SCThingOriginType = 'remote' | 'user';
/**
* Possible types of an origin
*/
export enum SCThingOriginType {
Remote = 'remote',
User = 'user',
}
/**
* Origin of a thing
@@ -149,7 +155,7 @@ export interface SCThingRemoteOrigin extends SCThingOrigin {
/**
* Type of the origin
*/
type: 'remote';
type: SCThingOriginType.Remote;
/**
* Main URL of the origin
@@ -174,7 +180,7 @@ export interface SCThingUserOrigin extends SCThingOrigin {
/**
* Type of the origin
*/
type: 'user';
type: SCThingOriginType.User;
/**
* When the saved thing was last updated with the latest state (e.g. from the backend)

View File

@@ -41,6 +41,9 @@ export type SCFavoriteDataTypes = SCAcademicEventWithoutReferences
* @validatable
*/
export interface SCFavorite extends SCSaveableThing<SCFavoriteDataTypes> {
/**
* Type of a favorite
*/
type: SCThingType.Favorite;
}