mirror of
https://github.com/waku-org/js-waku.git
synced 2025-02-09 02:53:38 +00:00
Rename to page direction
As the direction only affects the page ordering, not the message ordering in the pages.
This commit is contained in:
parent
087f5bf774
commit
f5a0416efd
@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- **Breaking**: Renamed `WakuStore.QueryOptions`'s `direction` to `pageDirection` (and its type) as it only affects the page ordering,
|
||||||
|
not the ordering of messages with the page.
|
||||||
|
|
||||||
## [0.13.1] - 2021-09-21
|
## [0.13.1] - 2021-09-21
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { useEffect, useReducer, useState } from 'react';
|
import { useEffect, useReducer, useState } from 'react';
|
||||||
import './App.css';
|
import './App.css';
|
||||||
import { Direction, getBootstrapNodes, Waku, WakuMessage } from 'js-waku';
|
import { PageDirection, getBootstrapNodes, Waku, WakuMessage } from 'js-waku';
|
||||||
import handleCommand from './command';
|
import handleCommand from './command';
|
||||||
import Room from './Room';
|
import Room from './Room';
|
||||||
import { WakuContext } from './WakuContext';
|
import { WakuContext } from './WakuContext';
|
||||||
@ -64,7 +64,7 @@ async function retrieveStoreMessages(
|
|||||||
try {
|
try {
|
||||||
const res = await waku.store.queryHistory([ChatContentTopic], {
|
const res = await waku.store.queryHistory([ChatContentTopic], {
|
||||||
pageSize: 5,
|
pageSize: 5,
|
||||||
direction: Direction.FORWARD,
|
pageDirection: PageDirection.FORWARD,
|
||||||
timeFilter: {
|
timeFilter: {
|
||||||
startTime,
|
startTime,
|
||||||
endTime,
|
endTime,
|
||||||
|
@ -20,6 +20,6 @@ export {
|
|||||||
|
|
||||||
export { WakuRelay, RelayCodecs } from './lib/waku_relay';
|
export { WakuRelay, RelayCodecs } from './lib/waku_relay';
|
||||||
|
|
||||||
export { Direction, WakuStore, StoreCodec } from './lib/waku_store';
|
export { PageDirection, WakuStore, StoreCodec } from './lib/waku_store';
|
||||||
|
|
||||||
export * as proto from './proto';
|
export * as proto from './proto';
|
||||||
|
@ -3,7 +3,7 @@ import { v4 as uuid } from 'uuid';
|
|||||||
|
|
||||||
import * as proto from '../../proto/waku/v2/store';
|
import * as proto from '../../proto/waku/v2/store';
|
||||||
|
|
||||||
export enum Direction {
|
export enum PageDirection {
|
||||||
BACKWARD = 'backward',
|
BACKWARD = 'backward',
|
||||||
FORWARD = 'forward',
|
FORWARD = 'forward',
|
||||||
}
|
}
|
||||||
@ -11,7 +11,7 @@ export enum Direction {
|
|||||||
export interface Params {
|
export interface Params {
|
||||||
contentTopics: string[];
|
contentTopics: string[];
|
||||||
pubSubTopic: string;
|
pubSubTopic: string;
|
||||||
direction: Direction;
|
pageDirection: PageDirection;
|
||||||
pageSize: number;
|
pageSize: number;
|
||||||
startTime?: number;
|
startTime?: number;
|
||||||
endTime?: number;
|
endTime?: number;
|
||||||
@ -25,7 +25,7 @@ export class HistoryRPC {
|
|||||||
* Create History Query.
|
* Create History Query.
|
||||||
*/
|
*/
|
||||||
static createQuery(params: Params): HistoryRPC {
|
static createQuery(params: Params): HistoryRPC {
|
||||||
const direction = directionToProto(params.direction);
|
const direction = directionToProto(params.pageDirection);
|
||||||
const pagingInfo = {
|
const pagingInfo = {
|
||||||
pageSize: params.pageSize,
|
pageSize: params.pageSize,
|
||||||
cursor: params.cursor,
|
cursor: params.cursor,
|
||||||
@ -67,11 +67,13 @@ export class HistoryRPC {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function directionToProto(direction: Direction): proto.PagingInfo_Direction {
|
function directionToProto(
|
||||||
switch (direction) {
|
pageDirection: PageDirection
|
||||||
case Direction.BACKWARD:
|
): proto.PagingInfo_Direction {
|
||||||
|
switch (pageDirection) {
|
||||||
|
case PageDirection.BACKWARD:
|
||||||
return proto.PagingInfo_Direction.DIRECTION_BACKWARD_UNSPECIFIED;
|
return proto.PagingInfo_Direction.DIRECTION_BACKWARD_UNSPECIFIED;
|
||||||
case Direction.FORWARD:
|
case PageDirection.FORWARD:
|
||||||
return proto.PagingInfo_Direction.DIRECTION_FORWARD;
|
return proto.PagingInfo_Direction.DIRECTION_FORWARD;
|
||||||
default:
|
default:
|
||||||
return proto.PagingInfo_Direction.DIRECTION_BACKWARD_UNSPECIFIED;
|
return proto.PagingInfo_Direction.DIRECTION_BACKWARD_UNSPECIFIED;
|
||||||
|
@ -19,7 +19,7 @@ import {
|
|||||||
getPublicKey,
|
getPublicKey,
|
||||||
} from '../waku_message/version_1';
|
} from '../waku_message/version_1';
|
||||||
|
|
||||||
import { Direction } from './history_rpc';
|
import { PageDirection } from './history_rpc';
|
||||||
|
|
||||||
const dbg = debug('waku:test:store');
|
const dbg = debug('waku:test:store');
|
||||||
|
|
||||||
@ -94,7 +94,7 @@ describe('Waku Store', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const messages = await waku.store.queryHistory([], {
|
const messages = await waku.store.queryHistory([], {
|
||||||
direction: Direction.FORWARD,
|
pageDirection: PageDirection.FORWARD,
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(messages?.length).eq(15);
|
expect(messages?.length).eq(15);
|
||||||
|
@ -12,13 +12,13 @@ import { hexToBuf } from '../utils';
|
|||||||
import { DefaultPubSubTopic } from '../waku';
|
import { DefaultPubSubTopic } from '../waku';
|
||||||
import { WakuMessage } from '../waku_message';
|
import { WakuMessage } from '../waku_message';
|
||||||
|
|
||||||
import { Direction, HistoryRPC } from './history_rpc';
|
import { HistoryRPC, PageDirection } from './history_rpc';
|
||||||
|
|
||||||
const dbg = debug('waku:store');
|
const dbg = debug('waku:store');
|
||||||
|
|
||||||
export const StoreCodec = '/vac/waku/store/2.0.0-beta3';
|
export const StoreCodec = '/vac/waku/store/2.0.0-beta3';
|
||||||
|
|
||||||
export { Direction };
|
export { PageDirection };
|
||||||
|
|
||||||
export interface CreateOptions {
|
export interface CreateOptions {
|
||||||
/**
|
/**
|
||||||
@ -40,7 +40,7 @@ export interface TimeFilter {
|
|||||||
export interface QueryOptions {
|
export interface QueryOptions {
|
||||||
peerId?: PeerId;
|
peerId?: PeerId;
|
||||||
pubSubTopic?: string;
|
pubSubTopic?: string;
|
||||||
direction?: Direction;
|
pageDirection?: PageDirection;
|
||||||
pageSize?: number;
|
pageSize?: number;
|
||||||
timeFilter?: TimeFilter;
|
timeFilter?: TimeFilter;
|
||||||
callback?: (messages: WakuMessage[]) => void;
|
callback?: (messages: WakuMessage[]) => void;
|
||||||
@ -93,7 +93,7 @@ export class WakuStore {
|
|||||||
const opts = Object.assign(
|
const opts = Object.assign(
|
||||||
{
|
{
|
||||||
pubSubTopic: this.pubSubTopic,
|
pubSubTopic: this.pubSubTopic,
|
||||||
direction: Direction.BACKWARD,
|
pageDirection: PageDirection.BACKWARD,
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
},
|
},
|
||||||
options,
|
options,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user