UNPKG

textiot

Version:

A framework for building web and native (IoT) Dapps on the IPFS network

54 lines (53 loc) 2.6 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); const api_1 = require("../core/api"); /** * Feed is an API module for paginating post and annotation block types * * @extends API */ class Feed extends api_1.API { /** * Retrieves post (join|leave|files|message) and annotation (comment|like) block type * * The mode option dictates how the feed is displayed: * * chrono: All feed block types are shown. Annotations always nest their target post, * i.e., the post a comment is about. * * annotated: Annotations are nested under post targets, but are not shown in the * top-level feed. * * stacks: Related blocks are chronologically grouped into 'stacks'. A new stack is * started if an unrelated block breaks continuity. This mode is used by Textile Photos. * Stacks may include: * * The initial post with some nested annotations. Newer annotations may have already been * listed. * * One or more annotations about a post. The newest annotation assumes the 'top' position in * the stack. Additional annotations are nested under the target. * * Newer annotations may have already been listed in the case as well. * * @param thread Thread ID (can also use ‘default’) * @param offset Offset ID to start listing from (omit for latest) * @param limit List page size (default: 5) * @param mode Feed mode (one of 'chrono’, 'annotated’, or ‘stacks’) */ list(thread, offset, limit, mode) { return __awaiter(this, void 0, void 0, function* () { const response = yield this.sendGet('feed', undefined, { thread: thread || '', offset: offset || '', limit: limit || 5, mode: mode || 'chrono' }); return response.json(); }); } } exports.default = Feed;