Updated Lists to pull last viewed list from db

This commit is contained in:
Brian McGonagill 2024-07-30 10:30:10 -05:00
parent be07ec72bd
commit 3ad8fab67b
5 changed files with 97 additions and 6 deletions

View file

@ -2,11 +2,13 @@ import { ListItems } from '../../imports/api/listItems.js'
import { Lists } from '../../imports/api/lists.js';
import { Products } from '../../imports/api/products.js';
import { M } from '../lib/assets/materialize.js';
import { UserLast } from '../../imports/api/userLast.js';
Template.listItemsForm.onCreated(function() {
this.subscribe("myListItems", Session.get("listId"));
this.subscribe("myLists");
this.subscribe("myProducts");
this.subscribe("userLastView");
});
Template.listItemsForm.onRendered(function() {
@ -28,9 +30,16 @@ Template.listItemsForm.onRendered(function() {
Template.listItemsForm.helpers({
selListName: function() {
let selListId = Session.get("listId");
let selListId = "";
if (Session.get("listId")) {
selListId = Session.get("listId");
} else {
selListId = UserLast.findOne({ view: "List", userId: Meteor.userId() }).viewId;
}
let listInfo = Lists.findOne({ _id: selListId });
return listInfo.listName;
if (listInfo) {
return listInfo.listName;
}
},
itemProdName: function() {
return Products.find({});