mirror of
https://github.com/wekan/wekan.git
synced 2025-12-16 23:40:13 +01:00
Add session id SessionData
This commit is contained in:
parent
9eca4566bf
commit
9b6288e49c
3 changed files with 32 additions and 5 deletions
|
|
@ -98,7 +98,10 @@ BlazeComponent.extendComponent({
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
// console.log('getting results');
|
// console.log('getting results');
|
||||||
if (this.queryParams) {
|
if (this.queryParams) {
|
||||||
const sessionData = SessionData.findOne({ userId: Meteor.userId() });
|
const sessionData = SessionData.findOne({
|
||||||
|
userId: Meteor.userId(),
|
||||||
|
sessionId: SessionData.getSessionId(),
|
||||||
|
});
|
||||||
const cards = Cards.find({ _id: { $in: sessionData.cards } });
|
const cards = Cards.find({ _id: { $in: sessionData.cards } });
|
||||||
this.queryErrors = sessionData.errorMessages;
|
this.queryErrors = sessionData.errorMessages;
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
|
|
@ -310,7 +313,11 @@ BlazeComponent.extendComponent({
|
||||||
this.queryParams = params;
|
this.queryParams = params;
|
||||||
|
|
||||||
this.autorun(() => {
|
this.autorun(() => {
|
||||||
const handle = subManager.subscribe('globalSearch', params);
|
const handle = subManager.subscribe(
|
||||||
|
'globalSearch',
|
||||||
|
SessionData.getSessionId(),
|
||||||
|
params,
|
||||||
|
);
|
||||||
Tracker.nonreactive(() => {
|
Tracker.nonreactive(() => {
|
||||||
Tracker.autorun(() => {
|
Tracker.autorun(() => {
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,13 @@ SessionData.attachSchema(
|
||||||
type: String,
|
type: String,
|
||||||
optional: false,
|
optional: false,
|
||||||
},
|
},
|
||||||
|
sessionId: {
|
||||||
|
/**
|
||||||
|
* unique session ID
|
||||||
|
*/
|
||||||
|
type: String,
|
||||||
|
optional: false,
|
||||||
|
},
|
||||||
totalHits: {
|
totalHits: {
|
||||||
/**
|
/**
|
||||||
* total number of hits in the last report query
|
* total number of hits in the last report query
|
||||||
|
|
@ -78,4 +85,16 @@ SessionData.attachSchema(
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (!Meteor.isServer) {
|
||||||
|
SessionData.getSessionId = () => {
|
||||||
|
let sessionId = Session.get('sessionId');
|
||||||
|
if (!sessionId) {
|
||||||
|
sessionId = `${String(Meteor.userId())}-${String(Math.random())}`;
|
||||||
|
Session.set('sessionId', sessionId);
|
||||||
|
}
|
||||||
|
|
||||||
|
return sessionId;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export default SessionData;
|
export default SessionData;
|
||||||
|
|
|
||||||
|
|
@ -173,7 +173,8 @@ Meteor.publish('dueCards', function(allUsers = false) {
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
Meteor.publish('globalSearch', function(queryParams) {
|
Meteor.publish('globalSearch', function(sessionId, queryParams) {
|
||||||
|
check(sessionId, String);
|
||||||
check(queryParams, Object);
|
check(queryParams, Object);
|
||||||
|
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
|
|
@ -199,7 +200,7 @@ Meteor.publish('globalSearch', function(queryParams) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
SessionData.upsert({ userId: this.userId }, update);
|
SessionData.upsert({ userId: this.userId, sessionId }, update);
|
||||||
|
|
||||||
const boards = [];
|
const boards = [];
|
||||||
const swimlanes = [];
|
const swimlanes = [];
|
||||||
|
|
@ -236,7 +237,7 @@ Meteor.publish('globalSearch', function(queryParams) {
|
||||||
Swimlanes.find({ _id: { $in: swimlanes } }, { fields }),
|
Swimlanes.find({ _id: { $in: swimlanes } }, { fields }),
|
||||||
Lists.find({ _id: { $in: lists } }, { fields }),
|
Lists.find({ _id: { $in: lists } }, { fields }),
|
||||||
Users.find({ _id: { $in: users } }, { fields: Users.safeFields }),
|
Users.find({ _id: { $in: users } }, { fields: Users.safeFields }),
|
||||||
SessionData.find({ userId: this.userId }),
|
SessionData.find({ userId: this.userId, sessionId }),
|
||||||
];
|
];
|
||||||
|
|
||||||
if (cards) {
|
if (cards) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue