Skip to content

Commit

Permalink
re-implemented without timer
Browse files Browse the repository at this point in the history
  • Loading branch information
markgrahamdawson committed Dec 16, 2024
1 parent fa06c9f commit 9f2f7e0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
12 changes: 11 additions & 1 deletion src/components/cylc/log/Log.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
v-for="(log, index) in computedLogs"
:key="index"
:class="wordWrap ? 'text-pre-wrap' : 'text-pre'"
>{{ log }}</span></pre>
>{{ log }}</span>
</pre>
</template>

<script>
Expand Down Expand Up @@ -84,6 +85,15 @@ export default {
}
return logLine
}
},

watch: {
computedLogs: {
handler (val, old) {
this.$emit('updating')
},
deep: true
}
}
}

Expand Down
20 changes: 6 additions & 14 deletions src/views/Log.vue
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
:logs="results.lines"
:timestamps="timestamps"
:word-wrap="wordWrap"
@updating="updating"
/>
<!-- a div to use for autoscrolling -->
<div class="auto-scroll-end"></div>
Expand Down Expand Up @@ -414,7 +415,6 @@ export default {

data () {
return {
timer: null,
autoScroll: false,
controlGroups: [
{
Expand Down Expand Up @@ -498,6 +498,11 @@ export default {
el.scrollIntoView(options)
}
},
updating () {
if (this.autoScroll) {
this.scrollToElement('auto-scroll-end', { behavior: 'smooth' })
}
},
setOption (option, value) {
// used by the ViewToolbar to update settings
this[option] = value
Expand Down Expand Up @@ -582,25 +587,12 @@ export default {
},
},

beforeUnmount () {
clearInterval(this.timer)
},

watch: {
jobLog (val, old) {
// reset the filename when the log mode changes
this.file = null
// go back to last chosen job if we are switching back to job logs
this.relativeID = val ? this.previousRelativeID : null
},
autoScroll (val, old) {
if (old) {
clearInterval(this.timer)
} else {
this.timer = setInterval(() => {
this.scrollToElement('auto-scroll-end', { behavior: 'smooth' })
}, 1000)
}
}
},

Expand Down

0 comments on commit 9f2f7e0

Please sign in to comment.