mirror of
https://github.com/wekan/wekan.git
synced 2025-04-22 04:57:07 -04: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
|
||||
// console.log('getting results');
|
||||
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 } });
|
||||
this.queryErrors = sessionData.errorMessages;
|
||||
// eslint-disable-next-line no-console
|
||||
|
@ -310,7 +313,11 @@ BlazeComponent.extendComponent({
|
|||
this.queryParams = params;
|
||||
|
||||
this.autorun(() => {
|
||||
const handle = subManager.subscribe('globalSearch', params);
|
||||
const handle = subManager.subscribe(
|
||||
'globalSearch',
|
||||
SessionData.getSessionId(),
|
||||
params,
|
||||
);
|
||||
Tracker.nonreactive(() => {
|
||||
Tracker.autorun(() => {
|
||||
// eslint-disable-next-line no-console
|
||||
|
|
|
@ -25,6 +25,13 @@ SessionData.attachSchema(
|
|||
type: String,
|
||||
optional: false,
|
||||
},
|
||||
sessionId: {
|
||||
/**
|
||||
* unique session ID
|
||||
*/
|
||||
type: String,
|
||||
optional: false,
|
||||
},
|
||||
totalHits: {
|
||||
/**
|
||||
* 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;
|
||||
|
|
|
@ -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);
|
||||
|
||||
// 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 swimlanes = [];
|
||||
|
@ -236,7 +237,7 @@ Meteor.publish('globalSearch', function(queryParams) {
|
|||
Swimlanes.find({ _id: { $in: swimlanes } }, { fields }),
|
||||
Lists.find({ _id: { $in: lists } }, { fields }),
|
||||
Users.find({ _id: { $in: users } }, { fields: Users.safeFields }),
|
||||
SessionData.find({ userId: this.userId }),
|
||||
SessionData.find({ userId: this.userId, sessionId }),
|
||||
];
|
||||
|
||||
if (cards) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue