Skip to content

Conversation

O-Mutt
Copy link

@O-Mutt O-Mutt commented Aug 21, 2025

This adds a new "auto" refresh option to the UI for allowing an interval refresh. I have also implemented a setting that is stored in localStorage for the auto refresh interval. When the auto refresh is set it puts the value into localStorage to be re-used on each screen by default.


Here is the auto refresh in action with network traffic included:

Screen.Recording.2025-08-21.at.1.36.27.PM.mov

UI of baseline

Screenshot 2025-08-21 at 1 42 31 PM

UI w/hover

Screenshot 2025-08-21 at 1 42 35 PM

UI Clicked dropdown

Screenshot 2025-08-21 at 1 42 39 PM

UI showing animation of manual refresh button to indicate ongoing action

Screenshot 2025-08-21 at 1 42 42 PM

@O-Mutt O-Mutt force-pushed the feat/autoRefresh branch 3 times, most recently from f179836 to 620e3d7 Compare August 21, 2025 18:54
@O-Mutt O-Mutt changed the title feat: adding an auto refresh dropdown/toggle [IMP] web_refresher: adding an auto refresh dropdown/toggle Aug 21, 2025
@O-Mutt O-Mutt changed the title [IMP] web_refresher: adding an auto refresh dropdown/toggle [IMP] web_refresher: add auto refresh on interval Aug 21, 2025
@O-Mutt O-Mutt force-pushed the feat/autoRefresh branch 2 times, most recently from 1c710d5 to 9dde2b4 Compare August 21, 2025 19:11
title="Refresh"
tabindex="-1"
>
<i id="manual-refresh-icon" class="fa fa-refresh" />
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved the icons to an <i> to allow the fa-spin to be added and removed without spinning the whole button 🤣

id="manual-refresh-btn"
class="btn btn-secondary m-0"
aria-label="Refresh"
t-on-click="onClickRefresh"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maintain existing flow with the a reset of the new timeout when manually clicked

Comment on lines +25 to +29
<button
class="dropdown-item"
t-on-click="onChangeAutoRefreshInterval"
value="1000"
>1s</button>
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure 1s is really appropriate. I could easily be persuaded to remove 1s

Comment on lines +20 to +24
<button
class="dropdown-item"
t-on-click="onChangeAutoRefreshInterval"
value="-1"
>Off</button>
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used -1 as the "off" value to avoid null/undefined confusions. #javascriptthings

data-bs-toggle="dropdown"
aria-expanded="false"
>
Auto Refresh: Off
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Default text could be moved out to allow easier i18n

title="Refresh"
tabindex="-1"
>
<i id="manual-refresh-icon" class="fa fa-refresh" />
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added id for easy selections

} else {
intervalValue = `${intervalInSeconds}s`;
}
document.getElementById("manual-refresh-icon").classList.add("fa-spin");
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add fa-spin to show active auto refresh

} else {
const intervalInSeconds = this.refreshInterval / 1000;
if (intervalInSeconds >= 60) {
intervalValue = `${Math.floor(intervalInSeconds / 60)}min`;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

60s or more gets "min" added

Comment on lines 140 to 243
let intervalValue = "Off";
if (!this.refreshInterval || this.refreshInterval <= 0) {
intervalValue = "Off";
document.getElementById("manual-refresh-icon").classList.remove("fa-spin");
} else {
const intervalInSeconds = this.refreshInterval / 1000;
if (intervalInSeconds >= 60) {
intervalValue = `${Math.floor(intervalInSeconds / 60)}min`;
} else {
intervalValue = `${intervalInSeconds}s`;
}
document.getElementById("manual-refresh-icon").classList.add("fa-spin");
}
document.getElementById("auto-refresh-dd").textContent =
`Auto Refresh: ${intervalValue}`;
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewing this logic i don't love how it played out. I'm going to refactor

Comment on lines +87 to +139
// Check the refreshInterval is greater than 0 and start a timer for the next refresh
if (this.refreshInterval > 0) {
// Always attempt to clear a running timeout in case the refresh was done manually
if (typeof this.runningRefresherId === "number") {
clearTimeout(this.runningRefresherId);
}
this.runningRefresherId = setTimeout(() => {
this.refresh();
}, this.refreshInterval);
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consolidated logic for starting the refresh interval in the current refresh to allow recursive calls

Comment on lines 131 to 157
const newIntervalText =
clickedOption.textContent ?? clickedOption.target.textContent;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the xml button text as the interval on the label

@StefanRijnhart StefanRijnhart changed the title [IMP] web_refresher: add auto refresh on interval [18.0][IMP] web_refresher: add auto refresh on interval Sep 3, 2025
@StefanRijnhart StefanRijnhart added this to the 18.0 milestone Sep 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants