Skip to content

Commit 67e2d11

Browse files
committed
fix: deterministically sort footer badges
1 parent bcacb71 commit 67e2d11

File tree

2 files changed

+25
-17
lines changed

2 files changed

+25
-17
lines changed

app/assets/javascripts/views/footer/footer-view.pug

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@
7272
.sk-label Offline
7373
.sk-app-bar-item(ng-click='ctrl.refreshData()', ng-if='!ctrl.offline')
7474
.sk-label Refresh
75-
.sk-app-bar-item.border(ng-if='ctrl.dockShortcuts.length > 0')
76-
.sk-app-bar-item.dock-shortcut(ng-repeat='shortcut in ctrl.dockShortcuts')
75+
.sk-app-bar-item.border(ng-if='ctrl.state.dockShortcuts.length > 0')
76+
.sk-app-bar-item.dock-shortcut(ng-repeat='shortcut in ctrl.state.dockShortcuts')
7777
.sk-app-bar-item-column(
7878
ng-class="{'underline': shortcut.component.active}",
7979
ng-click='ctrl.selectShortcut(shortcut)'

app/assets/javascripts/views/footer/footer_view.ts

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,12 @@ type DockShortcut = {
3232
}
3333
}
3434

35-
class FooterViewCtrl extends PureViewCtrl {
35+
class FooterViewCtrl extends PureViewCtrl<{}, {
36+
outOfSync: boolean;
37+
hasPasscode: boolean;
38+
dataUpgradeAvailable: boolean;
39+
dockShortcuts: DockShortcut[];
40+
}> {
3641

3742
private $rootScope: ng.IRootScopeService
3843
private rooms: SNComponent[] = []
@@ -96,7 +101,10 @@ class FooterViewCtrl extends PureViewCtrl {
96101

97102
getInitialState() {
98103
return {
99-
hasPasscode: false
104+
outOfSync: false,
105+
dataUpgradeAvailable: false,
106+
hasPasscode: false,
107+
dockShortcuts: [],
100108
};
101109
}
102110

@@ -379,19 +387,19 @@ class FooterViewCtrl extends PureViewCtrl {
379387
icon: icon
380388
} as DockShortcut);
381389
}
382-
this.dockShortcuts = shortcuts.sort((a, b) => {
383-
/** Circles first, then images */
384-
const aType = a.icon.type;
385-
const bType = b.icon.type;
386-
if (aType === bType) {
387-
return 0;
388-
} else if (aType === 'circle' && bType === 'svg') {
389-
return -1;
390-
} else if (bType === 'circle' && aType === 'svg') {
391-
return 1;
392-
} else {
393-
return 0;
394-
}
390+
this.setState({
391+
dockShortcuts: shortcuts.sort((a, b) => {
392+
/** Circles first, then images */
393+
const aType = a.icon.type;
394+
const bType = b.icon.type;
395+
if (aType === 'circle' && bType === 'svg') {
396+
return -1;
397+
} else if (bType === 'circle' && aType === 'svg') {
398+
return 1;
399+
} else {
400+
return a.name.localeCompare(b.name);
401+
}
402+
})
395403
});
396404
}
397405

0 commit comments

Comments
 (0)