Merge pull request #416 from acelaya-forks/feature/prepend-visits

Feature/prepend visits
This commit is contained in:
Alejandro Celaya 2021-05-01 16:44:21 +02:00 committed by GitHub
commit 23ba140ff4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 16 additions and 15 deletions

View file

@ -19,6 +19,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
### Fixed
* [#413](https://github.com/shlinkio/shlink-web-client/issues/413) Fixed edit short URL form reflecting outdated info after navigating back from other section.
* [#412](https://github.com/shlinkio/shlink-web-client/issues/412) Ensured new visits coming from mercure hub are prepended and not appended, to keep proper sorting.
## [3.1.0] - 2021-03-29

12
package-lock.json generated
View file

@ -13118,7 +13118,7 @@
},
"load-json-file": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-2.0.0.tgz",
"resolved": "https://registry.yarnpkg.com/load-json-file/-/load-json-file-2.0.0.tgz",
"integrity": "sha1-eUfkIUmvgNaWy/eXvKq8/h/inKg=",
"dev": true,
"requires": {
@ -13164,7 +13164,7 @@
},
"parse-json": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz",
"resolved": "https://registry.yarnpkg.com/parse-json/-/parse-json-2.2.0.tgz",
"integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=",
"dev": true,
"requires": {
@ -13173,7 +13173,7 @@
},
"path-type": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/path-type/-/path-type-2.0.0.tgz",
"resolved": "https://registry.yarnpkg.com/path-type/-/path-type-2.0.0.tgz",
"integrity": "sha1-8BLMuEFbcJb8LaoQVMPXI4lZTHM=",
"dev": true,
"requires": {
@ -13182,13 +13182,13 @@
},
"pify": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz",
"resolved": "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz",
"integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=",
"dev": true
},
"read-pkg": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-2.0.0.tgz",
"resolved": "https://registry.yarnpkg.com/read-pkg/-/read-pkg-2.0.0.tgz",
"integrity": "sha1-jvHAYjxqbbDcZxPEv6xGMysjaPg=",
"dev": true,
"requires": {
@ -13199,7 +13199,7 @@
},
"read-pkg-up": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-2.0.0.tgz",
"resolved": "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-2.0.0.tgz",
"integrity": "sha1-a3KoBImE4MQeeVEP1en6mbO1Sb4=",
"dev": true,
"requires": {

View file

@ -44,7 +44,7 @@ export default buildReducer<VisitsInfo, OrphanVisitsCombinedAction>({
const { visits } = state;
const newVisits = createdVisits.map(({ visit }) => visit);
return { ...state, visits: [ ...visits, ...newVisits ] };
return { ...state, visits: [ ...newVisits, ...visits ] };
},
}, initialState);

View file

@ -58,7 +58,7 @@ export default buildReducer<ShortUrlVisits, ShortUrlVisitsCombinedAction>({
.filter(({ shortUrl }) => shortUrl && shortUrlMatches(shortUrl, shortCode, domain))
.map(({ visit }) => visit);
return { ...state, visits: [ ...visits, ...newVisits ] };
return { ...state, visits: [ ...newVisits, ...visits ] };
},
}, initialState);

View file

@ -52,7 +52,7 @@ export default buildReducer<TagVisits, TagsVisitsCombinedAction>({
.filter(({ shortUrl }) => shortUrl?.tags.includes(tag))
.map(({ visit }) => visit);
return { ...state, visits: [ ...visits, ...newVisits ] };
return { ...state, visits: [ ...newVisits, ...visits ] };
},
}, initialState);

View file

@ -64,7 +64,7 @@ describe('orphanVisitsReducer', () => {
expect(visits).toEqual(actionVisits);
});
it('appends a new visits on CREATE_VISIT', () => {
it('prepends new visits on CREATE_VISIT', () => {
const prevState = buildState({ visits: visitsMocks });
const { visits } = reducer(
@ -72,7 +72,7 @@ describe('orphanVisitsReducer', () => {
{ type: CREATE_VISITS, createdVisits: [{ visit: {} }, { visit: {} }] } as any,
);
expect(visits).toEqual([ ...visitsMocks, {}, {}]);
expect(visits).toEqual([{}, {}, ...visitsMocks ]);
});
it('returns new progress on GET_ORPHAN_VISITS_PROGRESS_CHANGED', () => {

View file

@ -66,9 +66,9 @@ describe('shortUrlVisitsReducer', () => {
});
it.each([
[{ shortCode: 'abc123' }, [ ...visitsMocks, {}]],
[{ shortCode: 'abc123' }, [{}, ...visitsMocks ]],
[{ shortCode: 'def456' }, visitsMocks ],
])('appends a new visit on CREATE_VISIT', (state, expectedVisits) => {
])('prepends new visits on CREATE_VISIT', (state, expectedVisits) => {
const shortUrl = {
shortCode: 'abc123',
};

View file

@ -66,9 +66,9 @@ describe('tagVisitsReducer', () => {
});
it.each([
[{ tag: 'foo' }, [ ...visitsMocks, {}]],
[{ tag: 'foo' }, [{}, ...visitsMocks ]],
[{ tag: 'bar' }, visitsMocks ],
])('appends a new visit on CREATE_VISIT', (state, expectedVisits) => {
])('prepends new visits on CREATE_VISIT', (state, expectedVisits) => {
const shortUrl = {
tags: [ 'foo', 'baz' ],
};