feeds-fun 1.13.3 → 1.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "feeds-fun",
3
- "version": "1.13.3",
3
+ "version": "1.14.1",
4
4
  "author": "Aliaksei Yaletski (Tiendil) <a.eletsky@gmail.com> (https://tiendil.org/)",
5
5
  "description": "Frontend for the Feeds Fun — web-based news reader",
6
6
  "keywords": [
package/src/logic/api.ts CHANGED
@@ -76,7 +76,7 @@ export async function getLastEntries({period}: {period: number}) {
76
76
  const entries = [];
77
77
 
78
78
  for (let rawEntry of response.entries) {
79
- const entry = t.entryFromJSON(rawEntry);
79
+ const entry = t.entryFromJSON(rawEntry, response.tagsMapping);
80
80
  entries.push(entry);
81
81
  }
82
82
 
@@ -92,7 +92,7 @@ export async function getEntriesByIds({ids}: {ids: t.EntryId[]}) {
92
92
  const entries = [];
93
93
 
94
94
  for (let rawEntry of response.entries) {
95
- const entry = t.entryFromJSON(rawEntry);
95
+ const entry = t.entryFromJSON(rawEntry, response.tagsMapping);
96
96
  entries.push(entry);
97
97
  }
98
98
 
@@ -184,49 +184,48 @@ export class Entry {
184
184
  }
185
185
  }
186
186
 
187
- export function entryFromJSON({
188
- id,
189
- feedId,
190
- title,
191
- url,
192
- tags,
193
- markers,
194
- score,
195
- scoreContributions,
196
- publishedAt,
197
- catalogedAt,
198
- body
199
- }: {
200
- id: string;
201
- feedId: string;
202
- title: string;
203
- url: string;
204
- tags: string[];
205
- markers: string[];
206
- score: number;
207
- scoreContributions: {[key: string]: number};
208
- publishedAt: string;
209
- catalogedAt: string;
210
- body: string | null;
211
- }): Entry {
187
+ export function entryFromJSON(
188
+ rawEntry: {
189
+ id: string;
190
+ feedId: string;
191
+ title: string;
192
+ url: string;
193
+ tags: number[];
194
+ markers: string[];
195
+ score: number;
196
+ scoreContributions: {[key: number]: number};
197
+ publishedAt: string;
198
+ catalogedAt: string;
199
+ body: string | null;
200
+ },
201
+ tagsMapping: {[key: number]: string}
202
+ ): Entry {
203
+ const contributions: {[key: string]: number} = {};
204
+
205
+ for (const key in rawEntry.scoreContributions) {
206
+ contributions[tagsMapping[key]] = rawEntry.scoreContributions[key];
207
+ }
208
+
212
209
  return new Entry({
213
- id: toEntryId(id),
214
- feedId: toFeedId(feedId),
215
- title,
216
- url: toURL(url),
217
- tags: tags,
218
- markers: markers.map((m: string) => {
210
+ id: toEntryId(rawEntry.id),
211
+ feedId: toFeedId(rawEntry.feedId),
212
+ title: rawEntry.title,
213
+ url: toURL(rawEntry.url),
214
+ tags: rawEntry.tags.map((t: number) => tagsMapping[t]),
215
+ markers: rawEntry.markers.map((m: string) => {
219
216
  if (m in e.reverseMarker) {
220
217
  return e.reverseMarker[m];
221
218
  }
222
219
 
223
220
  throw new Error(`Unknown marker: ${m}`);
224
221
  }),
225
- score: score,
226
- scoreContributions: scoreContributions,
227
- publishedAt: new Date(publishedAt),
228
- catalogedAt: new Date(catalogedAt),
229
- body: body
222
+ score: rawEntry.score,
223
+ // map keys from int to string
224
+ scoreContributions: contributions,
225
+ publishedAt: new Date(rawEntry.publishedAt),
226
+ catalogedAt: new Date(rawEntry.catalogedAt),
227
+
228
+ body: rawEntry.body
230
229
  });
231
230
  }
232
231