Beispiel #1
0
        public static object fetchNotifications(int pageNumber)
        {
            return(new ThunkAction <AppState>((dispatcher, getState) => {
                return NotificationApi.FetchNotifications(pageNumber)
                .Then(notificationResponse => {
                    var oldResults = notificationResponse.results;
                    if (oldResults != null && oldResults.Count > 0)
                    {
                        oldResults.ForEach(item => {
                            var data = item.data;
                            var user = new User {
                                id = data.userId,
                                fullName = data.fullname,
                                avatar = data.avatarWithCDN
                            };
                            dispatcher.dispatch(new UserMapAction {
                                userMap = new Dictionary <string, User> {
                                    { data.userId, user }
                                }
                            });
                        });
                    }

                    var notifications = getState().notificationState.notifications;
                    if (pageNumber == 1)
                    {
                        notifications = notificationResponse.results;
                    }
                    else
                    {
                        if (pageNumber <= notificationResponse.pageTotal)
                        {
                            notifications.AddRange(notificationResponse.results);
                        }
                    }

                    dispatcher.dispatch(new FetchNotificationsSuccessAction
                    {
                        pageTotal = notificationResponse.pageTotal, notifications = notifications
                    });
                })
                .Catch(err => { dispatcher.dispatch(new FetchNotificationsFailureAction()); });
            }));
        }
        public static object fetchNotifications(int pageNumber)
        {
            return(new ThunkAction <AppState>((dispatcher, getState) => {
                return NotificationApi.FetchNotifications(pageNumber)
                .Then(notificationResponse => {
                    var results = notificationResponse.results;
                    if (results != null && results.Count > 0)
                    {
                        var userMap = notificationResponse.userMap;
                        results.ForEach(item => {
                            var data = item.data;
                            var user = new User {
                                id = data.userId,
                                fullName = data.fullname,
                                avatar = data.avatarWithCDN
                            };
                            if (userMap.ContainsKey(key: data.userId))
                            {
                                userMap[key: data.userId] = user;
                            }
                            else
                            {
                                userMap.Add(key: data.userId, value: user);
                            }
                        });
                        dispatcher.dispatch(new UserMapAction {
                            userMap = userMap
                        });
                    }

                    dispatcher.dispatch(new FetchNotificationsSuccessAction {
                        page = notificationResponse.page,
                        pageNumber = pageNumber,
                        pageTotal = notificationResponse.pageTotal,
                        notifications = results,
                        mentions = notificationResponse.userMap.Values.ToList()
                    });
                })
                .Catch(err => { dispatcher.dispatch(new FetchNotificationsFailureAction()); });
            }));
        }
Beispiel #3
0
        private void Working()
        {
            Receive <StartListening>(msg =>
                                     Console.WriteLine($"Work has already started for user id {msg.UserId}"));

            Receive <ProcessNotification>(msg =>
            {
                NotificationApi.GetNotificationAsync(msg.UserId)
                .ContinueWith(task =>
                {
                    Console.WriteLine($"Received: {task.Result.Text}");
                    return(new ProcessNotification()
                    {
                        UserId = msg.UserId
                    });
                }).PipeTo(Self);
            });

            Receive <StopListening>(msg =>
            {
                Become(Idle);
                Console.WriteLine($"Stopped listening for {msg.UserId}");
            });
        }
 public void Init()
 {
     instance = new NotificationApi();
 }
Beispiel #5
0
 public static object fetchMakeAllSeen()
 {
     return(new ThunkAction <AppState>((dispatcher, getState) => NotificationApi.FetchMakeAllSeen()));
 }
 public SetIntersightNotificationAccountSubscription()
 {
     ApiInstance = new NotificationApi(Config);
     ModelObject = new NotificationAccountSubscription();
     MethodName  = "UpdateNotificationAccountSubscriptionWithHttpInfo";
 }
 public RemoveIntersightNotificationAccountSubscription()
 {
     ApiInstance = new NotificationApi(Config);
     MethodName  = "DeleteNotificationAccountSubscriptionWithHttpInfo";
 }
 public GetIntersightNotificationAccountSubscription()
 {
     ApiInstance = new NotificationApi(Config);
     MethodName  = "GetNotificationAccountSubscriptionListWithHttpInfo";
 }
        public static object fetchNotifications(int pageNumber)
        {
            return(new ThunkAction <AppState>((dispatcher, getState) => {
                return NotificationApi.FetchNotifications(pageNumber)
                .Then(notificationResponse => {
                    var oldResults = notificationResponse.results;
                    if (oldResults != null && oldResults.Count > 0)
                    {
                        var userMap = notificationResponse.userMap;
                        oldResults.ForEach(item => {
                            var data = item.data;
                            var user = new User {
                                id = data.userId,
                                fullName = data.fullname,
                                avatar = data.avatarWithCDN
                            };
                            if (userMap.ContainsKey(data.userId))
                            {
                                userMap[data.userId] = user;
                            }
                            else
                            {
                                userMap.Add(data.userId, user);
                            }
                        });
                        dispatcher.dispatch(new UserMapAction {
                            userMap = userMap
                        });
                    }

                    var mentions = getState().notificationState.mentions;
                    var notifications = getState().notificationState.notifications;
                    if (pageNumber == 1)
                    {
                        notifications = notificationResponse.results;
                        mentions = notificationResponse.userMap.Values.ToList();
                    }
                    else
                    {
                        if (pageNumber <= notificationResponse.pageTotal)
                        {
                            notifications.AddRange(notificationResponse.results);
                        }

                        foreach (var user in notificationResponse.userMap.Values)
                        {
                            if (!mentions.Contains(user))
                            {
                                mentions.Add(user);
                            }
                        }
                    }

                    dispatcher.dispatch(new FetchNotificationsSuccessAction {
                        pageTotal = notificationResponse.pageTotal, notifications = notifications,
                        mentions = mentions
                    });
                })
                .Catch(err => { dispatcher.dispatch(new FetchNotificationsFailureAction()); });
            }));
        }