Skip to content

Commit aa06e65

Browse files
committed
redesign auto-refresh UI
1 parent dd57abe commit aa06e65

File tree

4 files changed

+38
-7
lines changed

4 files changed

+38
-7
lines changed
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading

src/assets/index.html

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,20 @@
7878

7979
<header class="dropdown-header" role="heading" aria-level="2">Auto Refresh</header>
8080
<div class="row text-center m-0">
81-
<button class="dropdown-item col-4 px-0" :aria-pressed="!refreshRate" :class="{active: !refreshRate}" @click.stop="refreshRate = 0">0</button>
82-
<button class="dropdown-item col-4 px-0" :aria-pressed="refreshRate == 10" :class="{active: refreshRate == 10}" @click.stop="refreshRate = 10">10m</button>
83-
<button class="dropdown-item col-4 px-0" :aria-pressed="refreshRate == 30" :class="{active: refreshRate == 30}" @click.stop="refreshRate = 30">30m</button>
84-
<button class="dropdown-item col-4 px-0" :aria-pressed="refreshRate == 60" :class="{active: refreshRate == 60}" @click.stop="refreshRate = 60">1h</button>
85-
<button class="dropdown-item col-4 px-0" :aria-pressed="refreshRate == 120" :class="{active: refreshRate == 120}" @click.stop="refreshRate = 120">2h</button>
86-
<button class="dropdown-item col-4 px-0" :aria-pressed="refreshRate == 240" :class="{active: refreshRate == 240}" @click.stop="refreshRate = 240">4h</button>
81+
<button class="dropdown-item col-4 px-0"
82+
@click.stop="changeRefreshRate(-1)"
83+
:disabled="!refreshRate">
84+
<span class="icon">
85+
{% inline "chevron-down.svg" %}
86+
</span>
87+
</button>
88+
<div class="col-4 d-flex align-items-center justify-content-center">{{ refreshRateTitle }}</div>
89+
<button class="dropdown-item col-4 px-0"
90+
@click.stop="changeRefreshRate(1)" :disabled="refreshRate === refreshRateOptions.at(-1).value">
91+
<span class="icon">
92+
{% inline "chevron-up.svg" %}
93+
</span>
94+
</button>
8795
</div>
8896

8997
<div class="dropdown-divider"></div>

src/assets/javascripts/app.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,17 @@ var vm = new Vue({
252252
'refreshRate': s.refresh_rate,
253253
'authenticated': app.authenticated,
254254
'feed_errors': {},
255+
256+
'refreshRateOptions': [
257+
{ title: "0", value: 0 },
258+
{ title: "10m", value: 10 },
259+
{ title: "30m", value: 30 },
260+
{ title: "1h", value: 60 },
261+
{ title: "2h", value: 120 },
262+
{ title: "4h", value: 240 },
263+
{ title: "12h", value: 720 },
264+
{ title: "24h", value: 1440 },
265+
],
255266
}
256267
},
257268
computed: {
@@ -309,7 +320,11 @@ var vm = new Vue({
309320
contentVideos: function() {
310321
if (!this.itemSelectedDetails) return []
311322
return (this.itemSelectedDetails.media_links || []).filter(l => l.type === 'video')
312-
}
323+
},
324+
refreshRateTitle: function () {
325+
const entry = this.refreshRateOptions.find(o => o.value === this.refreshRate)
326+
return entry ? entry.title : '0'
327+
},
313328
},
314329
watch: {
315330
'theme': {
@@ -778,6 +793,12 @@ var vm = new Vue({
778793
if (target && scroll) scrollto(target, scroll)
779794
})
780795
},
796+
changeRefreshRate: function(offset) {
797+
const curIdx = this.refreshRateOptions.findIndex(o => o.value === this.refreshRate)
798+
if (curIdx <= 0 && offset < 0) return
799+
if (curIdx >= (this.refreshRateOptions.length - 1) && offset > 0) return
800+
this.refreshRate = this.refreshRateOptions[curIdx + offset].value
801+
},
781802
}
782803
})
783804

0 commit comments

Comments
 (0)