| Index: lib/subscriptionClasses.js |
| =================================================================== |
| --- a/lib/subscriptionClasses.js |
| +++ b/lib/subscriptionClasses.js |
| @@ -174,61 +174,81 @@ |
| if (url[0] != "~") |
| return new DownloadableSubscription(url, null); |
| return new SpecialSubscription(url); |
| }; |
| /** |
| * Deserializes a subscription |
| * |
| - * @param {Object} obj |
| + * @param {Map.<string,string>} map |
| * map of serialized properties and their values |
| * @return {Subscription} |
| * subscription or null if the subscription couldn't be created |
| */ |
| -Subscription.fromObject = function(obj) |
| +Subscription.fromMap = function(map) |
| { |
| let result; |
| - if (obj.url[0] != "~") |
| + |
| + let url = map.get("url"); |
| + let title = map.get("title"); |
| + if (url[0] != "~") |
| { |
| // URL is valid - this is a downloadable subscription |
| - result = new DownloadableSubscription(obj.url, obj.title); |
| - if ("downloadStatus" in obj) |
| - result._downloadStatus = obj.downloadStatus; |
| - if ("lastSuccess" in obj) |
| - result.lastSuccess = parseInt(obj.lastSuccess, 10) || 0; |
| - if ("lastCheck" in obj) |
| - result._lastCheck = parseInt(obj.lastCheck, 10) || 0; |
| - if ("expires" in obj) |
| - result.expires = parseInt(obj.expires, 10) || 0; |
| - if ("softExpiration" in obj) |
| - result.softExpiration = parseInt(obj.softExpiration, 10) || 0; |
| - if ("errors" in obj) |
| - result._errors = parseInt(obj.errors, 10) || 0; |
| - if ("version" in obj) |
| - result.version = parseInt(obj.version, 10) || 0; |
| - if ("requiredVersion" in obj) |
| - result.requiredVersion = obj.requiredVersion; |
| - if ("homepage" in obj) |
| - result._homepage = obj.homepage; |
| - if ("lastDownload" in obj) |
| - result._lastDownload = parseInt(obj.lastDownload, 10) || 0; |
| - if ("downloadCount" in obj) |
| - result.downloadCount = parseInt(obj.downloadCount, 10) || 0; |
| + result = new DownloadableSubscription(url, title); |
| + |
| + let downloadStatus = map.get("downloadStatus"); |
| + let lastSuccess = map.get("lastSuccess"); |
| + let lastCheck = map.get("lastCheck"); |
| + let expires = map.get("expires"); |
| + let softExpiration = map.get("softExpiration"); |
| + let errors = map.get("errors"); |
| + let version = map.get("version"); |
| + let requiredVersion = map.get("requiredVersion"); |
| + let homepage = map.get("homepage"); |
| + let lastDownload = map.get("lastDownload"); |
| + let downloadCount = map.get("downloadCount"); |
| + if (typeof downloadStatus != "undefined") |
| + result._downloadStatus = downloadStatus; |
| + if (typeof lastSuccess != "undefined") |
| + result.lastSuccess = parseInt(lastSuccess, 10) || 0; |
| + if (typeof lastCheck != "undefined") |
| + result._lastCheck = parseInt(lastCheck, 10) || 0; |
| + if (typeof expires != "undefined") |
| + result.expires = parseInt(expires, 10) || 0; |
| + if (typeof softExpiration != "undefined") |
| + result.softExpiration = parseInt(softExpiration, 10) || 0; |
| + if (typeof errors != "undefined") |
| + result._errors = parseInt(errors, 10) || 0; |
| + if (typeof version != "undefined") |
| + result.version = parseInt(version, 10) || 0; |
| + if (typeof requiredVersion != "undefined") |
| + result.requiredVersion = requiredVersion; |
| + if (typeof homepage != "undefined") |
| + result._homepage = homepage; |
| + if (typeof lastDownload != "undefined") |
| + result._lastDownload = parseInt(lastDownload, 10) || 0; |
| + if (typeof downloadCount != "undefined") |
| + result.downloadCount = parseInt(downloadCount, 10) || 0; |
| } |
| else |
| { |
| - result = new SpecialSubscription(obj.url, obj.title); |
| - if ("defaults" in obj) |
| - result.defaults = obj.defaults.split(" "); |
| + result = new SpecialSubscription(url, title); |
| + |
| + let defaults = map.get("defaults"); |
| + if (typeof defaults != "undefined") |
| + result.defaults = defaults.split(" "); |
| } |
| - if ("fixedTitle" in obj) |
| - result._fixedTitle = (obj.fixedTitle == "true"); |
| - if ("disabled" in obj) |
| - result._disabled = (obj.disabled == "true"); |
| + |
| + let fixedTitle = map.get("fixedTitle"); |
| + let disabled = map.get("disabled"); |
| + if (typeof fixedTitle != "undefined") |
| + result._fixedTitle = (fixedTitle == "true"); |
| + if (typeof disabled != "undefined") |
| + result._disabled = (disabled == "true"); |
| return result; |
| }; |
| /** |
| * Class for special filter subscriptions (user's filters) |
| * @param {string} url see Subscription() |
| * @param {string} [title] see Subscription() |