[O] Separate checkIndex

This commit is contained in:
Hykilpikonna
2019-12-21 13:40:34 -05:00
parent ac5549ccc4
commit 57f29262e3
+15 -4
View File
@@ -48,16 +48,13 @@ export default class NavController
*/
updateIndex(index: Index | string, history?: boolean)
{
// Convert index format if it is hash only
if (typeof index == 'string') index = {hash: index, identifier: index};
index = this.checkIndex(index);
// Call custom event
if (this.updateCallback != null) this.updateCallback();
// Null case
if (history == null) history = true;
if (index.title == null) index.title = FormatUtils.toTitleCase(index.hash);
// Record history or not
if (history)
{
@@ -78,6 +75,20 @@ export default class NavController
this.index = index;
}
/**
* Check index conversion
*
* @param index Hash and title | Hash only
* @return Index Hash and title
*/
private checkIndex(index: Index | string): Index
{
// Convert index format if it is hash only
if (typeof index == 'string') index = {hash: index, identifier: index};
if (index.title == null) index.title = FormatUtils.toTitleCase(index.hash);
return index;
}
get id(): string
{
return this.index.identifier