Fix crashes related to empty teams

This commit is contained in:
Guangcong Luo
2015-07-02 04:20:00 -04:00
parent 5a5f8e0c9a
commit 4aabfaf07f

View File

@@ -87,6 +87,8 @@ Storage.saveAllTeams = function() {
*********************************************************/
Storage.unpackAllTeams = function(buffer) {
if (!buffer) return [];
if (buffer.charAt(0) === '[') {
// old format
return JSON.parse(buffer).map(function (oldTeam) {
@@ -478,6 +480,7 @@ Storage.getTeamIcons = function(team) {
};
Storage.getPackedTeam = function(team) {
if (!team) return null;
if (team.iconCache === '!') {
// see the same case in Storage.getTeamIcons
team.team = Storage.packTeam(Storage.activeSetList);