Previously fetched not retaining when refetching or polling - apollo-client

I'm currently building a Twitter clone that needs the following features:
Infinite scrolling.
Show button when new tweets are available. Fetch new tweets when clicking on this button.
Regularly update reply, retweet and like count of fetched tweets.
I'm using relay pagination on my backend and fetchMore with the endCursor that is returned by a query of all tweets (first 5) on my frontend to allow infinite scrolling.
To detect if new tweets are available, I can use a subscription.
The problem is that when a new tweet is available and I poll or refetch the counters and new tweets, the already fetched items are falling off the page, or the already fetched pages should be fetched again. How to solve this?
I was expecting that the already fetched tweets were merged with the new tweets.

Related

How to select a range of items from Realm Database

I have a realm database used in my xamarin android and iOS application. I have an API which feeds data to my app in a paginated manner. Whenever returns data the same is added to the DB from a ViewModel, which is common for both Android and iOS. Afterward, a broadcast is sent to update the screen. On receiving the broadcast I am trying to fetch the new set of data from the database. Let's say initially I don't have any data and on receiving the first broadcast I will fetch all the items, say 10 items, on receiving the next broadcast how can I fetch all the items except the first 10 items, and so on. ie selecting data from table in such a way that in each query the start index or row number changes.

Refresh filters when new data comes in

I have a Google Spreadsheet with multiple sheets. We paste a table of data into sheet1 and all the other sheets have filters based basically on the 'membernumber' value in one of the columns (so that the mass data that gets imported gets sorted by our individual members). We then want to send an email with an updated table for each individual member (so therefore my script will access each individual sheet and copy the filtered table of data to the email message body).
But my question is for one of the early parts of this script: How can I make my Apps Script automatically refresh the filters in all of our sheets after we've imported the new data in sheet1? Right now we go manually and click the filter icon and re-select the member's number, or 0 if they don't have data for that day. It's killing me.
I know apps script doesn't have an AutoFilter method, but maybe with the Sheet API I can refresh them? I think this may be the method I need to call.
Let's say I have a sheet, would I just write:
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("example");
sheet.updateFilterView({"fields": *}); //since I want to update all filters, all fields on each sheet
I really wish the Google sheets API had some examples!

Does load next page on PFQueryTableViewController count as a server request?

I'm considering creating an alternative to PFQueryTableViewController because I need some functionality that isn't offered.
I'm curious if the Load Next Page button on PFQueryTableViewController results in a server call?
...because in my implementation I'm going to run a query each time I need to load another page. I'm hoping that this won't be more expensive than PFQueryTableViewController.
When queryForTable is called it keeps a record of how many objects of that queried class are needed to display in the PFQTVC. The count is updated every time loadNextPage is called and loads the necessary data to fill the remaining objectsPerPage that you set for the PFQTVC. If there are more objects that could be loaded into the table, the PFQTVC can create a custom "Load More Cell" to load the next page, or remain content. So by having to update the table for next page and someone add a new post on a twitter like app for example, it would need to request that data because its new.

Prevent listgrid from refreshing when setting data

I'm writing a webmail-application by using smartgwt.
I'm trying to use auto-search on TextItem.
The TextItem is added a keyup-Handler and go to server side to do sql search every time when user
key-in a word. (I don't use js search because the speed of ie is very slow when doing filtering)
Further more, i use DSResponse.setData to create the listgrid records.
The problem is when setData is called, the grid always has a "loading data" message during the search.
How can i prevent this? Or just like PickListProperties, no "loading data" message, grid show the result without refresh.
Thanks!!
The message will appear whenever the grid calls the server to retrieve the data.
However you can, get the entire data on load, and whenever the the user keys in a word, just filter the grid by creating a new criteria like this :-
Criteria criteria=new Criteria();
criteria.addCriteria("name",textBox.getValue());
grid.filterData(criteria);
This way the loading message would not appear and also it would save you trips to server.

Notification bar on website - how to avoid multiple notifications for same user

I am building a website that will notify users of certain changes to their account via a notification bar at the top of the screen (similar to the way SO notifies of new badges).
In my DB I have a table that list the events and also a flag to denote whether they have been notified of the change yet or not. The table is of the form :
UserID AccountEvent EventDescription HasBeenNotified
ABC123 1 Your price deal ends in 2 weeks FALSE
What I would like to achieve is:
Customer logs in and is shown notification (assuming one needs to
happen)
Customer clicks to acknowledge message
DB HasBeenNotified field set to TRUE (to acknowledge notification has occurred)
I have been able to achieve all this but there is a snag!
I am putting the events that need to be notified into the HttpRuntime.Cache with a 10 min expiry so I don't need to keep polling the DB.
The issue this creates for me is that a customer could potentially see multiple notifications of the same message until the cache expires, for example:
Customer logs in and app logic looks in cache and says customer ABC123 needs to be
notified of X
Customer then acknowledges message (which updates DB to set notification flag to TRUE)
Cache does not yet reflect updated DB so if customer navigates to new page the same notification message is fired (until cache expires)
As far as I know I cannot update the actual data within the Cache (can only Remove data from cache based on cache key).
Can anybody provide hints and tips of how to get around the issue of multiple notifications?
Why not burst the cache? Remove that key from the cache?
Or you can update the cache by setting it again to new HasBeenNotified value or even set it to null which you should deal with and accept as empty.
HttpRuntime.Cache["YourKey"] = "";//new object/value;

Resources