Ejemplo n.º 1
0
 public static object saveReadyStateToDB(SocketResponseSessionData data)
 {
     return(new ThunkAction <AppState>((dispatcher, getState) => {
         MessengerDBApi.SyncSaveReadyState(data);
         dispatcher.dispatch(new SaveReadyStateToDBSuccessAction());
         return Promise.Resolved();
     }));
 }
Ejemplo n.º 2
0
        public void updateSessionReadyData(SocketResponseSessionData sessionReadyData)
        {
            sessionReadyData.lobbyChannels.ForEach(channel => {
                this.updateNormalChannelLite(channel: channel);
                if (!this.joinedChannels.Contains(item: channel.id))
                {
                    this.joinedChannels.Add(item: channel.id);
                }
            });

            sessionReadyData.publicChannels.ForEach(channel => {
                this.updateNormalChannelLite(channel: channel);
                if (!this.joinedChannels.Contains(item: channel.id))
                {
                    this.joinedChannels.Add(item: channel.id);
                }
            });

            sessionReadyData.privateChannels.ForEach(channel => {
                this.updateNormalChannelLite(channel: channel);
                if (!this.joinedChannels.Contains(item: channel.id))
                {
                    this.joinedChannels.Add(item: channel.id);
                }
            });

            sessionReadyData.users.ForEach(user => {
                this.joinedChannels.ForEach(channelId => {
                    this.channelDict[key: channelId].updateMessageUser(user: user);
                });
            });

            sessionReadyData.lastMessages.ForEach(message => {
                var channelId = message.channelId;
                if (this.channelDict.TryGetValue(key: channelId, out var channel))
                {
                    channel.lastMessageId        = message.id;
                    channel.lastMessage          = ChannelMessageView.fromChannelMessageLite(message: message);
                    channel.lastMessage.author   = channel.getMember(userId: channel.lastMessage.author.id)?.user;
                    channel.lastMessage.mentions = channel.lastMessage.mentions?.Select(
                        user => channel.getMember(userId: user.id).user)?.ToList();
                }
            });

            sessionReadyData.readState.ForEach(readState => {
                var channelId = readState.channelId;
                if (this.channelDict.TryGetValue(key: channelId, out var channel))
                {
                    channel.mentioned = readState.mentionCount;
                    channel.unread    = channel.lastMessageId != null && readState.lastMessageId != null &&
                                        readState.lastMessageId.hexToLong() < channel.lastMessageId.hexToLong()
                        ? 1
                        : 0;
                    channel.lastReadMessageId = readState.lastMessageId;
                    channel.atMe = channel.mentioned > 0 && channel.unread > 0;
                }
            });
        }
Ejemplo n.º 3
0
        /*
         *
         * save the given ReadyState into DB
         *
         */
        public static void SyncSaveReadyState(SocketResponseSessionData data)
        {
            var readyJson = JsonConvert.SerializeObject(data);

            SQLiteDBManager.instance.SaveReadyState(
                new DBReadyStateLite {
                key       = DBReadyStateLite.DefaultReadyStateKey,
                readyJson = readyJson
            }
                );
        }