https://supabase.com/ logo
Join DiscordCommunities
Powered by
# help
  • f

    frubalu

    07/27/2021, 7:57 PM
    you're welcome!
  • f

    Flyken

    07/27/2021, 7:58 PM
    my project is getting super freaking extensive
  • f

    Flyken

    07/27/2021, 8:01 PM
    https://tenor.com/view/futurama-serious-stare-suspicious-gif-5319823
  • f

    Flyken

    07/27/2021, 8:01 PM
    i just realized something
  • f

    Flyken

    07/27/2021, 8:01 PM
    this needs to be a context
  • f

    Flyken

    07/27/2021, 8:02 PM
    or
  • f

    Flyken

    07/27/2021, 8:02 PM
    no
  • f

    frubalu

    07/27/2021, 8:03 PM
    that's up to you, whether you want it to be available across components/pages
  • f

    Flyken

    07/27/2021, 8:18 PM
    can i match multiple things in a supabase query?
  • f

    Flyken

    07/27/2021, 8:18 PM
    Copy code
    js
    {games.includes(curGame.id) ? (
                <Button onClick={()=>{
                  supabase.from('users_games').insert({user_id: user.id, game_id: curGame.id})
              }}>Subscribe</Button>
            ) : (
              <Button danger onClick={()=>{
                supabase.from('users_games').delete().eq('game_id', user.id)
            }}>Unubscribe</Button>
            )
            }
  • f

    Flyken

    07/27/2021, 8:18 PM
    i need to add the game, then delete it
  • f

    Flyken

    07/27/2021, 8:20 PM
    im going about this the wrong way
  • f

    frubalu

    07/27/2021, 8:34 PM
    first, i'd move those onClick methods outside to separate functions just to maintain your sanity
  • f

    Flyken

    07/27/2021, 8:34 PM
    i copied the code from the other fiel
  • f

    Flyken

    07/27/2021, 8:34 PM
    and i get this result
  • f

    Flyken

    07/27/2021, 8:34 PM

    https://i.imgur.com/P94iyZh.png▾

  • f

    Flyken

    07/27/2021, 8:34 PM
    it adds the games again after each reload
  • f

    Flyken

    07/27/2021, 8:35 PM
    if i refresh it resets
  • f

    frubalu

    07/27/2021, 8:35 PM
    so if you have a
    addGame()
    method, you could run that insert method, and filter out the one you have in state
  • f

    Flyken

    07/27/2021, 8:35 PM
    yea, does it on the home page too
  • f

    frubalu

    07/27/2021, 8:35 PM
    or i'm sorry, on addGame() you'd add the game to state
  • f

    frubalu

    07/27/2021, 8:36 PM
    and on the flip side, you'd run the delete method and filter out that game from state
  • f

    Flyken

    07/27/2021, 8:36 PM
    ye but like
  • f

    Flyken

    07/27/2021, 8:36 PM
  • f

    Flyken

    07/27/2021, 8:36 PM
    its filling the state with duplicates
  • f

    Flyken

    07/27/2021, 8:36 PM
    maybe check for dupes?
  • f

    frubalu

    07/27/2021, 8:37 PM
    why would there be a duplicate?
  • f

    Flyken

    07/27/2021, 8:37 PM
    ¯\_(ツ)_/¯
  • f

    frubalu

    07/27/2021, 8:37 PM
    they should have unique IDs
  • f

    Flyken

    07/27/2021, 8:37 PM
    it just keeps adding 3
1...101112...316Latest