Skip to content

Commit 85c58e1

Browse files
committed
Updated stories paging to work with changes in site behaviour
1 parent 994edac commit 85c58e1

File tree

3 files changed

+21
-22
lines changed

3 files changed

+21
-22
lines changed

js/Akun.js

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ import RealTimeConnection from './RealTimeConnection.js';
77
class Akun {
88
constructor(settings) {
99
this._settings = settings;
10-
this.core = new Core({ protocol: settings.protocol, hostname: settings.hostname });
10+
this.core = new Core({protocol: settings.protocol, hostname: settings.hostname});
1111
if (this._settings.connection) {
1212
this.connection = new RealTimeConnection(this, this._settings.connection);
1313
}
1414
// Special choice node in unpublished story devoted to divining the ephemeralUserId
1515
this._ephemeralUserId = null;
16-
this._ephemeralUserIdPromise = this.vote('DAjqaif2XdtjF9mPD', 0).then(({ user }) => {
16+
this._ephemeralUserIdPromise = this.vote('DAjqaif2XdtjF9mPD', 0).then(({user}) => {
1717
this._ephemeralUserId = user;
1818
return user;
1919
});
@@ -162,23 +162,23 @@ class Akun {
162162
'trash': true,
163163
'init': true
164164
};
165-
return this.core.post(`/api/anonkun/board/item`, { data });
165+
return this.core.post(`/api/anonkun/board/item`, {data});
166166
}
167167

168168
vote(choiceNodeId, choiceId) {
169169
const data = {
170170
'_id': choiceNodeId,
171171
'vote': choiceId
172172
};
173-
return this.core.post(`/api/anonkun/voteChapter`, { data });
173+
return this.core.post(`/api/anonkun/voteChapter`, {data});
174174
}
175175

176176
removeVote(choiceNodeId, choiceId) {
177177
const data = {
178178
'_id': choiceNodeId,
179179
'vote': choiceId
180180
};
181-
return this.core.delete(`/api/anonkun/voteChapter`, { data });
181+
return this.core.delete(`/api/anonkun/voteChapter`, {data});
182182
}
183183

184184
writeInChoice(choiceNodeId, value, storyId) {
@@ -190,7 +190,7 @@ class Akun {
190190
// Site does this but omitting it seems to work anyway
191191
data['r'] = [storyId];
192192
}
193-
return this.core.post(`/api/anonkun/customChoice`, { data });
193+
return this.core.post(`/api/anonkun/customChoice`, {data});
194194
}
195195

196196
openChoice(choiceNodeId) {
@@ -210,7 +210,7 @@ class Akun {
210210
// Site does this but omitting it seems to work anyway
211211
data['r'] = [storyId];
212212
}
213-
return this.core.post(`/api/anonkun/readerPost`, { data });
213+
return this.core.post(`/api/anonkun/readerPost`, {data});
214214
}
215215

216216
openReaderPost(readerPostNodeId) {
@@ -226,15 +226,15 @@ class Akun {
226226
blockFor: chatNodeId,
227227
blockFrom: storyId
228228
};
229-
return this.core.post(`/api/anonkun/ban`, { data, json: false });
229+
return this.core.post(`/api/anonkun/ban`, {data, json: false});
230230
}
231231

232232
unban(storyId, chatNodeId) {
233233
const data = {
234234
blockFor: chatNodeId,
235235
blockFrom: storyId
236236
};
237-
return this.core.delete(`/api/anonkun/ban`, { data, json: false });
237+
return this.core.delete(`/api/anonkun/ban`, {data, json: false});
238238
}
239239

240240
getBans(storyId) {
@@ -247,7 +247,7 @@ class Akun {
247247
deleteFrom: storyId,
248248
nid: chatNodeId
249249
};
250-
return this.core.delete(`/api/anonkun/node`, { data, json: false });
250+
return this.core.delete(`/api/anonkun/node`, {data, json: false});
251251
}
252252

253253
/**
@@ -265,8 +265,10 @@ class Akun {
265265
* @param {boolean} [options.storyStatus.finished=true] - Finished stories
266266
* @param {boolean} [options.storyStatus.hiatus=true] - Stories that met an untimely pause
267267
* @param {string} [options.sort] - How the results are sorted. Values can be:
268-
* - 'Latest': "Sort by the latest activity in the story, including chat posts"
269-
* - 'UpdatedChapter': "Sort by the latest posted chapter"
268+
* - 'active': "Sort by the latest activity in the story, including chat posts"
269+
* - 'chapter': "Sort by the latest posted chapter"
270+
* - 'replies': "Sort by the most commented stories"
271+
* - 'like': "Sort by the most liked stories"
270272
* - 'top': "Sort by the most commented stories"
271273
* - 'new': "Show the newest stories"
272274
* @param {string} [options.length] - Filter stories by length. Values can be:
@@ -280,6 +282,7 @@ class Akun {
280282
getStories(board = 'stories', page = 1, options) {
281283
const query = _.merge(
282284
{
285+
page,
283286
contentRating: {
284287
teen: true,
285288
mature: true,
@@ -290,16 +293,12 @@ class Akun {
290293
finished: true,
291294
hiatus: true
292295
},
293-
sort: 'Latest',
296+
sort: 'active',
294297
length: 'Any'
295298
},
296299
options
297300
);
298-
if (_.isNumber(page)) {
299-
return this.core.get(`/api/anonkun/board/${board}/${page}`, { query });
300-
} else {
301-
return this.core.get(`/api/anonkun/board/${board}`, { query });
302-
}
301+
return this.core.get(`/api/anonkun/board/${board}`, {query});
303302
}
304303

305304
_openNode(nodeId) {
@@ -311,7 +310,7 @@ class Akun {
311310
}
312311
}
313312
};
314-
return this.core.post(`/api/anonkun/editChapter`, { data, json: false });
313+
return this.core.post(`/api/anonkun/editChapter`, {data, json: false});
315314
}
316315

317316
_closeNode(nodeId) {
@@ -323,7 +322,7 @@ class Akun {
323322
}
324323
}
325324
};
326-
return this.core.post(`/api/anonkun/editChapter`, { data, json: false });
325+
return this.core.post(`/api/anonkun/editChapter`, {data, json: false});
327326
}
328327
}
329328

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "akun-api",
3-
"version": "5.0.1",
3+
"version": "5.0.2",
44
"description": "A module intended to enable easy interactions with Anonkun",
55
"main": "index.js",
66
"type": "module",

0 commit comments

Comments
 (0)