From 5b4f36a4192b55a30edc3a6910f2ca46124171c2 Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Mon, 14 Oct 2019 20:29:44 +0300 Subject: [PATCH] rm unused TimelinePostIntagram --- src/models/TimelinePostInstagram.js | 73 ----------------------------- 1 file changed, 73 deletions(-) delete mode 100644 src/models/TimelinePostInstagram.js diff --git a/src/models/TimelinePostInstagram.js b/src/models/TimelinePostInstagram.js deleted file mode 100644 index 7ad90352..00000000 --- a/src/models/TimelinePostInstagram.js +++ /dev/null @@ -1,73 +0,0 @@ -export default class TimelinePostInstagram { - constructor(date, image, url, username, userpic, text) { - this.type = 'instagram'; - - this.date = date; - this.image = image; - this.url = url; - this.username = username; - this.userpic = userpic; - this.text = text; - } -} - -export function fromInstagram1(post) { - //var author_id = personByInstagram(team.team, post.data.author); - //var name = author_id ? team.short(author_id) : post.data.author; - - const name = post.data.author || 'hudozka'; - const userpic = 'https://igcdn-photos-a-a.akamaihd.net/hphotos-ak-xaf1/t51.2885-19/11357496_464997000344800_2124591831_a.jpg'; - return new TimelinePostInstagram( - post.date, - post.data.image.standard_resolution.url, - post.data.url, - name, - userpic, - post.body - ); -} - -export function fromInstagram2(post) { - const caption = safe(post => post.data.caption.text, ''); - const username = safe(post => post.data.user['username'], ''); - const userpic = safe(post => post.data.user['profile_picture'], ''); - const image = safe(post => post.data.images['standard_resolution'].url, ''); - - return new TimelinePostInstagram( - post.date, - image(post), - post.data.link, - username(post), - userpic(post), - caption(post) - ); -} - -export const types = { - 'instagram-1': fromInstagram1, - 'instagram-2': fromInstagram2 -}; - -export function createInstance(post) { - if(post.type in types) { - let fn = types[post.type]; - - try{ - return fn(post); - }catch(e){ - return null; - } - } - return null; -} - -function safe(fn, defaultValue=null){ - return function(){ - try{ - let i = fn.apply(undefined, arguments); - return i ? i : defaultValue; - }catch(e){ - return defaultValue - } - } -}