Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visual feedback about pagination status #251

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

SaloEater
Copy link

Hi, I couldn't stand using market without understanding the status of pagination request so I made this small visualization

demo-status.mp4

Copy link
Member

@Step7750 Step7750 left a comment

Choose a reason for hiding this comment

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

Thank you for the contribution, I really appreciate it!

I hadn't realized how poor the state of navigating SCM has gotten -- pressing the "next" page after loading seemed to consistency fail for multiple tries without any extensions.

I've seen the extension receive 1 star reviews by users thinking the extension introduced this issue, so yeah, I'm thinking about how to integrate messaging in the status bar that indicates the request to Steam failed.

}, 1000);
}

class PaginationFailedBox extends HTMLElement {
Copy link
Member

Choose a reason for hiding this comment

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

Would it be possible for you to define this as a FloatElement that uses Lit?

You get a couple nice perks for that:

  1. Event handling (ie. click events) that have nicer syntactic sugar
  2. Render loop handling (prevents having to perform manual add/remove styles, changing the rendered HTML)
  3. Follows the convention for creating components across the code-base.

You can see other components in this parent folder for examples.

}
}

customElements.define('pagination-failed-box', PaginationFailedBox);
Copy link
Member

Choose a reason for hiding this comment

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

Preferable to use FloatElement with the decorator so that this happens for you.


customElements.define('pagination-failed-box', PaginationFailedBox);
const paginationBox = document.createElement('pagination-failed-box') as PaginationFailedBox;
document.body.appendChild(paginationBox);
Copy link
Member

Choose a reason for hiding this comment

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

I'd prefer a decorator (perhaps in the family of @InjectX) -- perhaps call it InjectBody()? There may also be an element on the page that may make more sense to inject into (perhaps closer to the results page).

}

export function initResponseRenderResultsStatus() {
const id = setInterval(() => {
Copy link
Member

Choose a reason for hiding this comment

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

I think it'd be better to get something like this abstracted like Observe in utils.

For instance, WaitUntilDefined and make it a bit more generic.

@@ -0,0 +1,155 @@
function overrideOnResponseRenderResults(proto: any) {
Copy link
Member

Choose a reason for hiding this comment

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

These functions can be included as part of the inner impl of the component, specifically when it starts you can handle getting the proto reference and overriding. Since at the end of the day, it is tightly coupled anyways and isn't capable of operating outside of a global reference to that component.


proto.OnResponseRenderResults = function(responseClass: any) {
const success = (responseClass && responseClass.responseJSON && responseClass.responseJSON.success) || false;
if (!success) {
Copy link
Member

Choose a reason for hiding this comment

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

nit: Anti-pattern to do:

if (!var) {
   // this
} else {
   // that
}

instead of

if (var) {
   // that
} else {
   // this
}

const originalMethod = proto.OnResponseRenderResults;

proto.OnResponseRenderResults = function(responseClass: any) {
const success = (responseClass && responseClass.responseJSON && responseClass.responseJSON.success) || false;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
const success = (responseClass && responseClass.responseJSON && responseClass.responseJSON.success) || false;
const success = !!responseClass?.responseJSON?.success;

}, 1000);
}

class PaginationFailedBox extends HTMLElement {
Copy link
Member

Choose a reason for hiding this comment

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

PaginationFailedBox seems to be a bit of a misleading term since it also showing "pending" status.

How about PaginationStatusBox?


init('src/lib/page_scripts/market_listing.js', main);

async function main() {}
async function main() {
initResponseRenderResultsStatus()
Copy link
Member

Choose a reason for hiding this comment

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

As mentioned in another comment, it's preferrable for a decorator of the component to handle it's own injection into the page, so that you don't need to handle creation manually here.

Then you just need to import the file.

private progressBar: HTMLDivElement;
private messageDiv: HTMLDivElement;
private hideTimeout: number | null = null;
private timeoutDuration: number = 1;
Copy link
Member

@Step7750 Step7750 Sep 18, 2024

Choose a reason for hiding this comment

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

This has no clear units, for example, it seems to represent 5s increments for showing pending and seconds for error.

You should put the units in the variable name (ie. timeoutMs) and use it consistently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants