使用MessageClicks表跟踪已读/未读的用户消息吗? [英] Keep track of read/unread User Messages with a MessageClicks table?

查看:95
本文介绍了使用MessageClicks表跟踪已读/未读的用户消息吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为我的应用程序用户实现简单的收件箱系统,以便可以彼此发送基本消息,就像在许多论坛系统中一样.

I'm trying to implement a simple Inbox system for users of my app so that can send basic messages to each other - just like in many forum systems.

如果为User has_many :messages,如何跟踪自上次阅读以来未读的消息并通知用户?

If User has_many :messages, how do I keep track of and notify the User of messages unread since last time they were read?

我认为需要将Messages屏幕链接上的点击记录在单独的表格( MessagesClicks )中.

I'm thinking clicks on the link to the Messages screen need to be recorded in a separate table (MessagesClicks).

这是最好的方法吗?

因此,我然后检查MessagesClicks表,以查看自从上次单击链接以来是否有任何新消息到达-基于last_clickedupdated_at字段.

So then I check the MessagesClicks table to see if any new messages have arrived since the last time that link was clicked - based on a last_clicked or updated_at field.

推荐答案

我会跟踪何时在消息本身上读取消息,默认值为null.

I would keep track of when a message was read on the message itself with the default value of null.

如果用户有任何dateRead值为null的消息,则他们有未读消息.

If the user has any Messages with a dateRead value of null then they have unread messages.

在消息"屏幕上向用户显示消息时,将消息的dateRead属性从null更新为现在.

When you display a message to the user on the Messages screen, update the dateRead property of the message from null to now.

这篇关于使用MessageClicks表跟踪已读/未读的用户消息吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆