Sync: add support for timestamp on set.

This commit is contained in:
Paul
2021-06-01 11:09:13 +01:00
parent 0aabceafa4
commit ec88333a83
3 changed files with 6 additions and 4 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "revolt.js",
"version": "4.1.3-alpha.5",
"version": "4.1.3-alpha.6",
"main": "dist/index.js",
"repository": "https://gitlab.insrt.uk/revolt/revolt.js",
"author": "Paul Makles <insrt.uk>",
+4 -2
View File
@@ -300,15 +300,17 @@ export class Client extends EventEmitter {
/**
* Set user settings for current user.
* @param data Data to set as an object. Any non-string values will be automatically serialised.
* @param timestamp Timestamp to use for the current revision.
*/
async syncSetSettings(data: { [key: string]: object | string }) {
async syncSetSettings(data: { [key: string]: object | string }, timestamp?: number) {
let requestData: { [key: string]: string } = {};
for (let key of Object.keys(data)) {
let value = data[key];
requestData[key] = typeof value === 'string' ? value : JSON.stringify(value);
}
await this.req('POST', '/sync/settings/set', requestData);
let query = timestamp ? `?timestamp=${timestamp}` : '';
await this.req('POST', `/sync/settings/set${query}` as '/sync/settings/set', requestData);
}
/**
+1 -1
View File
@@ -1,7 +1,7 @@
export * from './Client';
export { Channel, User, Message } from './api/objects';
export const LIBRARY_VERSION = '4.1.3-alpha.5';
export const LIBRARY_VERSION = '4.1.3-alpha.6';
export const defaultConfig = {
apiURL: 'https://api.revolt.chat',