blob: 73d9a4f7e22390d919853f3043a4a8eb96ff023f [file] [log] [blame]
Adrià Vilanova Martínez6c4739a2022-11-07 00:11:53 +01001import {CCApi} from '../../../../common/api.js';
2import {getAuthUser} from '../../../../common/communityConsoleUtils.js';
3
4export default class ReadStateRunner {
5 execute(readState, thread) {
6 // Although this should in theory be the last message ID, it seems like
7 // setting 0 marks the entire thread as read anyways.
8 const lastMessageId = readState ? '0' : '-1';
9
10 return CCApi(
11 'SetUserReadStateBulk', {
12 // bulkItem:
13 1: [{
14 1: thread.forumId,
15 2: thread.threadId,
16 3: lastMessageId,
17 }],
18 },
19 /* authenticated = */ true, getAuthUser());
20 }
21}