GithubHelp home page GithubHelp logo

Unread indicator no longer works about photon HOT 4 CLOSED

pbui avatar pbui commented on August 19, 2024
Unread indicator no longer works

from photon.

Comments (4)

Xyphyn avatar Xyphyn commented on August 19, 2024 1

Like this

setInterval(async () => {
  if (!get(profile)) return

  const { user, jwt } = get(profile)!
  if (!jwt || !user) return

  const response = await getClient().getUnreadCount({
    auth: jwt,
  })

  user.unreads =
    response.mentions + response.private_messages + response.replies

  if (amModOfAny(user)) {
    const reports = await getClient().getReportCount({
      auth: jwt,
    })

    user.reports =
      reports.comment_reports +
      reports.post_reports +
      (reports.private_message_reports ?? 0)
  }

  profile.update((p) => ({
    ...p!,
    user: user,
  }))
}, 30 * 1000)

from photon.

Xyphyn avatar Xyphyn commented on August 19, 2024

Will fix today

from photon.

Xyphyn avatar Xyphyn commented on August 19, 2024

This is because of how stores work. in .svelte files, the compiler automatically converts the stores to be reactive, but in TS files, get isn't reactive. so you have to use store.update()

from photon.

pbui avatar pbui commented on August 19, 2024

Ah, OK. I tried doing update() on user but got runtime errors... didn't think of updating the user inside of the profile.

from photon.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.