mirror of
				https://github.com/MCV-Software/TWBlue.git
				synced 2025-11-02 21:07:05 +00:00 
			
		
		
		
	TWBlue should no longer load old items in buffer
This commit is contained in:
		@@ -7,6 +7,7 @@ TWBlue Changelog
 | 
			
		||||
    * TWBlue can display image descriptions within Tweet templates. For that, you can use the $image_description variable in your template.
 | 
			
		||||
* We have restored conversation and threads support powered by Twitter API V2 thanks to a set of improvements we have done in the application, as well as more generous limits to Tweet monthly cap by Twitter.
 | 
			
		||||
* In the Windows 11 Keymap, the default shortcut to open the keystrokes editor is now CTRL+Alt+Windows+K to avoid conflicts with the new global mute microphone shortcut.
 | 
			
		||||
* TWBlue should no longer load old tweets in buffers.
 | 
			
		||||
* Fixed issue when uploading attachments (images, videos or gif files) while sending tweets or replies.
 | 
			
		||||
* Fixed an error that was making TWBlue to ask for a restart after saving account settings, even if such restart was not required. ([#413,](https://github.com/manuelcortez/TWBlue/issues/413))
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -142,7 +142,7 @@ class BaseBuffer(base.Buffer):
 | 
			
		||||
            log.debug("Starting stream for buffer %s, account %s and type %s" % (self.name, self.account, self.type))
 | 
			
		||||
            log.debug("args: %s, kwargs: %s" % (self.args, self.kwargs))
 | 
			
		||||
            if self.name != "direct_messages":
 | 
			
		||||
                val = self.session.call_paged(self.function, *self.args, **self.kwargs)
 | 
			
		||||
                val = self.session.call_paged(self.function, self.name, *self.args, **self.kwargs)
 | 
			
		||||
            else:
 | 
			
		||||
                # 50 results are allowed per API call, so let's assume max value can be 50.
 | 
			
		||||
                # reference: https://developer.twitter.com/en/docs/twitter-api/v1/direct-messages/sending-and-receiving/api-reference/list-events
 | 
			
		||||
 
 | 
			
		||||
@@ -256,21 +256,22 @@ class Session(base.baseSession):
 | 
			
		||||
        tl = self.call_paged("favorites", *args, **kwargs)
 | 
			
		||||
        return self.order_buffer(name, tl)
 | 
			
		||||
 | 
			
		||||
    def call_paged(self, update_function, *args, **kwargs):
 | 
			
		||||
    def call_paged(self, update_function, name, *args, **kwargs):
 | 
			
		||||
        """ Makes a call to the Twitter API methods several times. Useful for get methods.
 | 
			
		||||
        this function is needed for retrieving more than 200 items.
 | 
			
		||||
        update_function str: The function to call. This function must be child of self.twitter
 | 
			
		||||
        args and kwargs are passed to update_function.
 | 
			
		||||
        returns a list with all items retrieved."""
 | 
			
		||||
        max = 0
 | 
			
		||||
        results = []
 | 
			
		||||
        data = getattr(self.twitter, update_function)(count=self.settings["general"]["max_tweets_per_call"], *args, **kwargs)
 | 
			
		||||
        if self.db.get(name) == None or self.db.get(name) == []:
 | 
			
		||||
            last_id = None
 | 
			
		||||
        else:
 | 
			
		||||
            if self.settings["general"]["reverse_timelines"] == False:
 | 
			
		||||
                last_id = self.db[name][0].id
 | 
			
		||||
            else:
 | 
			
		||||
                last_id = self.db[name][-1].id
 | 
			
		||||
        data = getattr(self.twitter, update_function)(count=self.settings["general"]["max_tweets_per_call"], since_id=last_id, *args, **kwargs)
 | 
			
		||||
        results.extend(data)
 | 
			
		||||
        for i in range(0, max):
 | 
			
		||||
            if i == 0: max_id = results[-1].id
 | 
			
		||||
            else: max_id = results[0].id
 | 
			
		||||
            data = getattr(self.twitter, update_function)(max_id=max_id, count=self.settings["general"]["max_tweets_per_call"], *args, **kwargs)
 | 
			
		||||
            results.extend(data)
 | 
			
		||||
        results.reverse()
 | 
			
		||||
        return results
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user