textiot
Version:
A framework for building web and native (IoT) Dapps on the IPFS network
93 lines (92 loc) • 2.99 kB
JavaScript
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 });
exports.ignoreInvite = exports.acceptInvite = exports.readAll = exports.read = exports.countUnread = exports.list = void 0;
const react_native_1 = require("react-native");
const buffer_1 = require("buffer");
const model_1 = require("./model");
const { NotificationsBridge } = react_native_1.NativeModules;
/**
* List all Notifications.
* ```typescript
* Textile.notifications.list(offset, limit);
* ```
*/
function list(offset, limit) {
return __awaiter(this, void 0, void 0, function* () {
const result = yield NotificationsBridge.list(offset, limit);
return model_1.NotificationList.decode(buffer_1.Buffer.from(result, 'base64'));
});
}
exports.list = list;
/**
* Get count of unread Notifications.
* ```typescript
* Textile.notifications.countUnread();
* ```
*/
function countUnread() {
return __awaiter(this, void 0, void 0, function* () {
const result = yield NotificationsBridge.countUnread();
return result;
});
}
exports.countUnread = countUnread;
/**
* Mark a Notification as read by ID.
* ```typescript
* Textile.notifications.read(id);
* ```
*/
function read(id_) {
return __awaiter(this, void 0, void 0, function* () {
yield NotificationsBridge.read(id_);
});
}
exports.read = read;
/**
* Mark all Notifications as read.
* ```typescript
* Textile.notifications.readAll();
* ```
*/
function readAll() {
return __awaiter(this, void 0, void 0, function* () {
yield NotificationsBridge.readAll();
});
}
exports.readAll = readAll;
/**
* Accept an Invite included in a Notification.
* ```typescript
* Textile.notifications.acceptInvite(id);
* ```
*/
function acceptInvite(id_) {
return __awaiter(this, void 0, void 0, function* () {
const result = yield NotificationsBridge.acceptInvite(id_);
return result;
});
}
exports.acceptInvite = acceptInvite;
/**
* Ignore an Invite included in a Notification.
* ```typescript
* Textile.notifications.ignoreInvite(id);
* ```
*/
function ignoreInvite(id_) {
return __awaiter(this, void 0, void 0, function* () {
const result = yield NotificationsBridge.ignoreInvite(id_);
return result;
});
}
exports.ignoreInvite = ignoreInvite;
;