mirror of
https://github.com/smogon/pokemon-showdown-client.git
synced 2026-08-22 02:51:35 -05:00
Add a toggle for syncing remote teams to device
This commit is contained in:
@@ -472,6 +472,7 @@
|
||||
'change select[name=bg]': 'setBg',
|
||||
'change select[name=timestamps-lobby]': 'setTimestampsLobby',
|
||||
'change select[name=timestamps-pms]': 'setTimestampsPMs',
|
||||
'change input[name=syncteams]': 'setSyncTeams',
|
||||
'change select[name=onepanel]': 'setOnePanel',
|
||||
'change select[name=theme]': 'setTheme',
|
||||
'change input[name=logchat]': 'setLogChat',
|
||||
@@ -564,7 +565,8 @@
|
||||
buf += '<p><label class="optlabel">Timestamps in chat rooms: <select name="timestamps-lobby" class="button"><option value="off">Off</option><option value="minutes"' + (timestamps.lobby === 'minutes' ? ' selected="selected"' : '') + '>[HH:MM]</option><option value="seconds"' + (timestamps.lobby === 'seconds' ? ' selected="selected"' : '') + '>[HH:MM:SS]</option></select></label></p>';
|
||||
buf += '<p><label class="optlabel">Timestamps in PMs: <select name="timestamps-pms" class="button"><option value="off">Off</option><option value="minutes"' + (timestamps.pms === 'minutes' ? ' selected="selected"' : '') + '>[HH:MM]</option><option value="seconds"' + (timestamps.pms === 'seconds' ? ' selected="selected"' : '') + '>[HH:MM:SS]</option></select></label></p>';
|
||||
buf += '<p><label class="optlabel">Chat preferences: <button name="formatting" class="button">Text formatting</button></label></p>';
|
||||
|
||||
var syncTeams = !Storage.prefs('nosyncteams');
|
||||
buf += '<p><label class="optlabel">Download teams from server: <input type="checkbox" name="syncteams" ' + (syncTeams ? 'checked ' : '') + '></input></p>';
|
||||
if (window.nodewebkit) {
|
||||
buf += '<hr />';
|
||||
buf += '<p><strong>Desktop app</strong></p>';
|
||||
@@ -673,6 +675,17 @@
|
||||
this.timestamps.pms = e.currentTarget.value;
|
||||
Storage.prefs('timestamps', this.timestamps);
|
||||
},
|
||||
setSyncTeams: function () {
|
||||
Storage.prefs('nosyncteams', !Storage.prefs('nosyncteams'));
|
||||
if (!Storage.prefs('nosyncteams')) {
|
||||
Storage.loadRemoteTeams(function () {
|
||||
if (app.rooms.teambuilder) {
|
||||
// if they have it open, be sure to update so it doesn't show 'no teams'
|
||||
app.rooms.teambuilder.update();
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
avatars: function () {
|
||||
app.addPopup(AvatarsPopup);
|
||||
},
|
||||
|
||||
@@ -620,6 +620,7 @@ Storage.compareTeams = function (serverTeam, localTeam) {
|
||||
};
|
||||
|
||||
Storage.loadRemoteTeams = function (after) {
|
||||
if (Storage.prefs('nosyncteams')) return;
|
||||
$.get(app.user.getActionPHP(), { act: 'getteams' }, Storage.safeJSON(function (data) {
|
||||
if (data.actionerror) {
|
||||
return app.addPopupMessage('Error loading uploaded teams: ' + data.actionerror);
|
||||
|
||||
@@ -433,7 +433,7 @@ export class TeamViewer extends preact.Component<PageProps> {
|
||||
copyTeam() {
|
||||
if (!this.state.team) return;
|
||||
const team = unpackTeam(this.state.team.team);
|
||||
navigator.clipboard.writeText(team.map(exportSet).join('\n'));
|
||||
navigator.clipboard.writeText(team.map(exportSet).join('\n\n'));
|
||||
clearTimeout(this.state.copyButtonUsed);
|
||||
this.setState({
|
||||
copyButtonUsed: setTimeout(() => this.setState({ copyButtonUsed: undefined }), 3000),
|
||||
|
||||
Reference in New Issue
Block a user