Commit 3e8e6384 authored by Daniel Kreuter's avatar Daniel Kreuter
Browse files

Fixed timelines of user lists

User lists are now fully working again.

CCBUG: 264091
REVIEW: 111855
parent 85315390
......@@ -736,30 +736,45 @@ void TwitterApiMicroBlog::requestTimeLine ( Choqok::Account* theAccount, QString
int countOfPost = Choqok::BehaviorSettings::countOfPosts();
QOAuth::ParamMap params;
if( account->usingOAuth() ){ //TODO: Check if needed
// needed because lists have different parameter names but
// returned timelines have the same JSON format
if(timelineApiPath[type].contains("lists/statuses")) {
// type contains @username/timelinename, we only need the timeline name here
int index = type.indexOf("/");
QString slug = type.mid(index + 1);
url.addQueryItem("slug", slug);
params.insert("slug", slug.toLatin1());
url.addQueryItem("owner_screen_name", theAccount->username());
params.insert("owner_screen_name", theAccount->username().toLatin1());
} else {
if( account->usingOAuth() ){ //TODO: Check if needed
if ( !latestStatusId.isEmpty() ) {
params.insert ( "since_id", latestStatusId.toLatin1() );
countOfPost = 200;
}
params.insert ( "count", QByteArray::number( countOfPost ) );
if ( !maxId.isEmpty() ) {
params.insert ( "max_id", maxId.toLatin1() );
}
if ( page ) {
params.insert ( "page", QByteArray::number ( page ) );
}
}
if ( !latestStatusId.isEmpty() ) {
params.insert ( "since_id", latestStatusId.toLatin1() );
url.addQueryItem ( "since_id", latestStatusId );
countOfPost = 200;
}
params.insert ( "count", QByteArray::number( countOfPost ) );
url.addQueryItem ( "count", QString::number( countOfPost ) );
if ( !maxId.isEmpty() ) {
params.insert ( "max_id", maxId.toLatin1() );
url.addQueryItem ( "max_id", maxId );
}
if ( page ) {
params.insert ( "page", QByteArray::number ( page ) );
url.addQueryItem ( "page", QString::number ( page ) );
}
}
if ( !latestStatusId.isEmpty() ) {
url.addQueryItem ( "since_id", latestStatusId );
countOfPost = 200;
}
url.addQueryItem ( "count", QString::number( countOfPost ) );
if ( !maxId.isEmpty() ) {
url.addQueryItem ( "max_id", maxId );
}
if ( page ) {
url.addQueryItem ( "page", QString::number ( page ) );
}
kDebug() << "Latest " << type << " Id: " << latestStatusId;// << " apiReq: " << url;
KIO::StoredTransferJob *job = KIO::storedGet ( url, KIO::Reload, KIO::HideProgressInfo ) ;
......
......@@ -308,24 +308,20 @@ void TwitterMicroBlog::addListTimeline( TwitterAccount* theAccount, const QStrin
addTimelineName(name);
theAccount->setTimelineNames(tms);
theAccount->writeConfig();
QString url = QString("/%1/lists/%2/statuses").arg(username).arg(listname);
QString url = QString("/lists/statuses");
timelineApiPath[name] = url + ".%1";
updateTimelines(theAccount);
}
// TODO: Change to new API
void TwitterMicroBlog::setListTimelines(TwitterAccount* theAccount, const QStringList& lists)
{
kDebug()<<lists;
QStringList tms = theAccount->timelineNames();
foreach(const QString &name, lists){
QString lst = name;
lst.remove(0, 1);
QStringList userlist = lst.split('/');
QString username = userlist[0], listname = userlist[1];
tms.append(name);
addTimelineName(name);
QString url = QString("/%1/lists/%2/statuses").arg(username).arg(listname);
QString url = QString("/lists/statuses");
timelineApiPath[name] = url + ".%1";
}
tms.removeDuplicates();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment