| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 /** The top-level collection of all sections for a user. */ | 5 /** The top-level collection of all sections for a user. */ |
| 6 // TODO(jimhug): This is known as UserData in the server model. | 6 // TODO(jimhug): This is known as UserData in the server model. |
| 7 class Sections implements Collection<Section> { | 7 class Sections implements Collection<Section> { |
| 8 final List<Section> _sections; | 8 final List<Section> _sections; |
| 9 | 9 |
| 10 Sections(this._sections); | 10 Sections(this._sections); |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 | 133 |
| 134 /** Provider of a news feed. */ | 134 /** Provider of a news feed. */ |
| 135 class Feed { | 135 class Feed { |
| 136 String id; | 136 String id; |
| 137 final String title; | 137 final String title; |
| 138 final String iconUrl; | 138 final String iconUrl; |
| 139 final String description; | 139 final String description; |
| 140 ObservableList<Article> articles; | 140 ObservableList<Article> articles; |
| 141 ObservableValue<bool> error; // TODO(jimhug): Check if dead code. | 141 ObservableValue<bool> error; // TODO(jimhug): Check if dead code. |
| 142 | 142 |
| 143 Feed(this.id, this.title, this.iconUrl, [description = '']) | 143 Feed(this.id, this.title, this.iconUrl, [this.description = '']) |
| 144 : this.description = description, | 144 : articles = new ObservableList<Article>(), |
| 145 articles = new ObservableList<Article>(), | |
| 146 error = new ObservableValue<bool>(false); | 145 error = new ObservableValue<bool>(false); |
| 147 | 146 |
| 148 static Feed decode(Decoder decoder) { | 147 static Feed decode(Decoder decoder) { |
| 149 final sourceId = decoder.readString(); | 148 final sourceId = decoder.readString(); |
| 150 final sourceTitle = decoder.readString(); | 149 final sourceTitle = decoder.readString(); |
| 151 final sourceIcon = decoder.readString(); | 150 final sourceIcon = decoder.readString(); |
| 152 final feed = new Feed(sourceId, sourceTitle, sourceIcon); | 151 final feed = new Feed(sourceId, sourceTitle, sourceIcon); |
| 153 final nItems = decoder.readInt(); | 152 final nItems = decoder.readInt(); |
| 154 | 153 |
| 155 for (int i=0; i < nItems; i++) { | 154 for (int i=0; i < nItems; i++) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 176 String textBody; // TODO(jimhug): rename to snipppet. | 175 String textBody; // TODO(jimhug): rename to snipppet. |
| 177 final Feed dataSource; // TODO(jimhug): rename to feed. | 176 final Feed dataSource; // TODO(jimhug): rename to feed. |
| 178 String _htmlBody; | 177 String _htmlBody; |
| 179 String srcUrl; | 178 String srcUrl; |
| 180 final ObservableValue<bool> unread; // TODO(jimhug): persist to server. | 179 final ObservableValue<bool> unread; // TODO(jimhug): persist to server. |
| 181 | 180 |
| 182 bool error; // TODO(jimhug): Check if this is dead and remove. | 181 bool error; // TODO(jimhug): Check if this is dead and remove. |
| 183 | 182 |
| 184 Article(this.dataSource, this.id, this.date, this.title, this.author, | 183 Article(this.dataSource, this.id, this.date, this.title, this.author, |
| 185 this.srcUrl, this.hasThumbnail, this.textBody, | 184 this.srcUrl, this.hasThumbnail, this.textBody, |
| 186 [htmlBody = null, bool unread = true, error = false]) | 185 [this._htmlBody = null, bool unread = true, this.error = false]) |
| 187 : unread = new ObservableValue<bool>(unread), | 186 : unread = new ObservableValue<bool>(unread); |
| 188 this._htmlBody = htmlBody, | |
| 189 this.error = error; | |
| 190 | 187 |
| 191 String get htmlBody() { | 188 String get htmlBody() { |
| 192 _ensureLoaded(); | 189 _ensureLoaded(); |
| 193 return _htmlBody; | 190 return _htmlBody; |
| 194 } | 191 } |
| 195 | 192 |
| 196 String get dataUri() { | 193 String get dataUri() { |
| 197 return Uri.encodeComponent(id).replaceAll( | 194 return Uri.encodeComponent(id).replaceAll( |
| 198 ',', '%2C').replaceAll('%2F', '/'); | 195 ',', '%2C').replaceAll('%2F', '/'); |
| 199 } | 196 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 final srcUrl = decoder.readString(); | 234 final srcUrl = decoder.readString(); |
| 238 final hasThumbnail = decoder.readBool(); | 235 final hasThumbnail = decoder.readBool(); |
| 239 final author = decoder.readString(); | 236 final author = decoder.readString(); |
| 240 final dateInSeconds = decoder.readInt(); | 237 final dateInSeconds = decoder.readInt(); |
| 241 final snippet = decoder.readString(); | 238 final snippet = decoder.readString(); |
| 242 final date = new Date.fromEpoch(dateInSeconds*1000, new TimeZone.utc()); | 239 final date = new Date.fromEpoch(dateInSeconds*1000, new TimeZone.utc()); |
| 243 return new Article(source, id, date, title, author, srcUrl, hasThumbnail, | 240 return new Article(source, id, date, title, author, srcUrl, hasThumbnail, |
| 244 snippet); | 241 snippet); |
| 245 } | 242 } |
| 246 } | 243 } |
| OLD | NEW |