mirror of
https://github.com/chylex/TweetDuck.git
synced 2024-12-04 22:42:49 +01:00
31 lines
771 B
JavaScript
31 lines
771 B
JavaScript
import { TD } from "../../api/td.js";
|
|
|
|
export const COLUMN_NOT_FOUND = "column";
|
|
export const TWEET_NOT_FOUND = "tweet";
|
|
|
|
/**
|
|
* @param {string} columnId
|
|
* @param {string} chirpId
|
|
* @param {function(column: TD_Column, chirp: ChirpBase)} onSuccess
|
|
* @param {function("column"|"tweet")} onError
|
|
*/
|
|
export function retrieveTweet(columnId, chirpId, onSuccess, onError) {
|
|
const column = TD.controller.columnManager.getByApiid(columnId);
|
|
if (!column) {
|
|
onError(COLUMN_NOT_FOUND);
|
|
return;
|
|
}
|
|
|
|
const chirp = column.findMostInterestingChirp(chirpId);
|
|
if (chirp) {
|
|
onSuccess(column, chirp);
|
|
}
|
|
else {
|
|
TD.controller.clients.getPreferredClient().show(chirpId, function(chirp) {
|
|
onSuccess(column, chirp);
|
|
}, function() {
|
|
onError(TWEET_NOT_FOUND);
|
|
});
|
|
}
|
|
}
|