WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Fix toast spam #262

@brucetony

Description

@brucetony

When polling the PO, if it down or disconnected then toast messages will spam the user. this should be fixed by either using groups, limiting lifespan of message to 0, a flag, or some combination of the three e.g.

const apiState = ref({
  isDown: false
});

async function someApiCall() {
  try {
    const response = await api.call();
    if (apiState.value.isDown) {
      apiState.value.isDown = false;
      toast.add({
        severity: 'success',
        summary: 'Connected',
        detail: 'Connection restored',
        life: 3000
      });
    }
  } catch (error) {
    if (!apiState.value.isDown) {
      apiState.value.isDown = true;
      toast.add({
        severity: 'error',
        summary: 'Connection Error',
        detail: 'Unable to reach server',
        group: 'api-error',
        life: 0 // Sticky until resolved
      });
    }
  }
}

This will likely need to be implemented in the hubApi fetch plugin

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions