| 61 | |
| 62 | @singleton() |
| 63 | export class StatusBarService |
| 64 | extends Component<IStatusBar> |
| 65 | implements IStatusBarService |
| 66 | { |
| 67 | protected state: IStatusBar; |
| 68 | |
| 69 | constructor() { |
| 70 | super(); |
| 71 | this.state = container.resolve(StatusBarModel); |
| 72 | } |
| 73 | |
| 74 | /** |
| 75 | * Get the item informations in right position or left position |
| 76 | * @param item |
| 77 | * @returns |
| 78 | */ |
| 79 | private getItem(item: IStatusBarItem, float?: Float): StatusBarItemInfos { |
| 80 | const { rightItems, leftItems } = this.state; |
| 81 | |
| 82 | if (!float) { |
| 83 | // find left first |
| 84 | let index = leftItems.findIndex(searchById(item.id)); |
| 85 | |
| 86 | if (index > -1) { |
| 87 | return { |
| 88 | index, |
| 89 | item: leftItems[index], |
| 90 | source: 'leftItems', |
| 91 | }; |
| 92 | } |
| 93 | |
| 94 | // then find the item from right |
| 95 | index = rightItems.findIndex(searchById(item.id)); |
| 96 | if (index > -1) { |
| 97 | return { |
| 98 | index, |
| 99 | item: rightItems[index], |
| 100 | source: 'rightItems', |
| 101 | }; |
| 102 | } |
| 103 | |
| 104 | // nothing found both in right and left |
| 105 | return { |
| 106 | index: -1, |
| 107 | item: null, |
| 108 | source: null, |
| 109 | }; |
| 110 | } |
| 111 | // specific the position |
| 112 | const sourceArr = float === Float.left ? leftItems : rightItems; |
| 113 | const index = sourceArr.findIndex(searchById(item.id)); |
| 114 | return { |
| 115 | index, |
| 116 | item: sourceArr[index] || null, |
| 117 | source: float === Float.left ? 'leftItems' : 'rightItems', |
| 118 | }; |
| 119 | } |
| 120 |
nothing calls this directly
no outgoing calls
no test coverage detected