diff --git a/play.pokemonshowdown.com/js/client.js b/play.pokemonshowdown.com/js/client.js index 9e9a5a260..1aa07ca6d 100644 --- a/play.pokemonshowdown.com/js/client.js +++ b/play.pokemonshowdown.com/js/client.js @@ -987,6 +987,7 @@ function toId() { team.privacy = data.privacy; team.team = data.team; team.loaded = true; + Storage.saveTeams(); callback(team); var entry = app.loadingTeamQueue.shift(); if (entry) { diff --git a/teams.pokemonshowdown.com/src/teams-search.tsx b/teams.pokemonshowdown.com/src/teams-search.tsx index 6466b758a..e9c9d095f 100644 --- a/teams.pokemonshowdown.com/src/teams-search.tsx +++ b/teams.pokemonshowdown.com/src/teams-search.tsx @@ -1,7 +1,7 @@ /** @jsx preact.h */ /** @jsxFrag preact.Fragment */ import preact from '../../play.pokemonshowdown.com/js/lib/preact'; -import { Net, type ServerTeam, MiniTeam } from './utils'; +import { Net, type ServerTeam, MiniTeam, query } from './utils'; import type { PageProps } from './teams'; import { Config } from '../../play.pokemonshowdown.com/src/client-main'; @@ -84,16 +84,9 @@ export class TeamSearcher extends preact.Component { for (const k in this.state.search) { if (!this.state.search[k]) delete this.state.search[k]; } - void Net('/api/searchteams').get({ + void query('searchteams', { query: { ...this.state.search, format, count: this.state.curCount }, - }).then(resultText => { - if (resultText.startsWith(']')) resultText = resultText.slice(1); - let result; - try { - result = JSON.parse(resultText); - } catch { - result = { actionerror: "Malformed response received. Try again later." }; - } + }).then(result => { this.setState({ ...result, loading: false }); }); } diff --git a/teams.pokemonshowdown.com/src/teams-view.tsx b/teams.pokemonshowdown.com/src/teams-view.tsx index 1608ca963..1809373de 100644 --- a/teams.pokemonshowdown.com/src/teams-view.tsx +++ b/teams.pokemonshowdown.com/src/teams-view.tsx @@ -1,7 +1,7 @@ /** @jsx preact.h */ /** @jsxFrag preact.Fragment */ import preact from '../../play.pokemonshowdown.com/js/lib/preact'; -import { Net, PSIcon, getShowdownUsername, unpackTeam } from './utils'; +import { PSIcon, getShowdownUsername, unpackTeam, query } from './utils'; import { BattleLog } from '../../play.pokemonshowdown.com/src/battle-log'; import type { PageProps } from './teams'; import { Dex } from '../../play.pokemonshowdown.com/src/battle-dex'; @@ -213,6 +213,8 @@ export class TeamViewer extends preact.Component { changesMade: false, teamEdits: null as { format?: string, private?: number } | null, editError: null as null | string, + copied: null as null | string, + copyError: null as null | string, }; constructor(props: PageProps) { super(props); @@ -239,6 +241,8 @@ export class TeamViewer extends preact.Component { const is2Col = this.state.displayMode === '2col'; const isDark = document.querySelector('html')?.classList[0] === 'dark'; const link = this.id + (this.state.team.private ? `-${this.state.team.private}` : ''); + const loggedin = toID(getShowdownUsername()); + const manageClass = this.state.manageOpen ? `button notifying` : `button`; return
@@ -250,10 +254,9 @@ export class TeamViewer extends preact.Component { https://psim.us/t/{link}

- {toID(getShowdownUsername()) === this.state.team.ownerid && } + {loggedin === this.state.team.ownerid ? + : + loggedin && }