From 4291d4e442913b5d4f57cc035fb8051b4ce150ef Mon Sep 17 00:00:00 2001 From: Bastard Operator Date: Sun, 10 Jan 2021 15:21:49 +0100 Subject: [PATCH] Improvements on Meet Account profile images loading --- src/routes/_components/status/MeetStatus.html | 12 +++++++- src/scss/themes/ozark.scss | 8 ++++- static/fedilove-no-react.js | 30 +++++++++++++++---- 3 files changed, 43 insertions(+), 7 deletions(-) diff --git a/src/routes/_components/status/MeetStatus.html b/src/routes/_components/status/MeetStatus.html index 7dafa77c..71a9961d 100644 --- a/src/routes/_components/status/MeetStatus.html +++ b/src/routes/_components/status/MeetStatus.html @@ -136,7 +136,17 @@ ), accountId: ({ account }) => account.id, avatarHeader: ({ account }) => account.header, - originalAccount: ({ originalStatus }) => originalStatus.account, + originalAccount: ({ originalStatus }) => { + if (process.browser) { + if (window.localStorage.store_meetAccounts === undefined) + window.localStorage.store_meetAccounts = '{}'; + const aJson = JSON.parse(window.localStorage.store_meetAccounts); + if (aJson[originalStatus.account.id] === undefined) + aJson[originalStatus.account.id] = originalStatus.account; + window.localStorage.store_meetAccounts = JSON.stringify(aJson); + } + return originalStatus.account + }, originalAccountId: ({ originalAccount }) => originalAccount.id, accountMeetAge: ({ originalAccount }) => { const fieldVal = originalAccount.fields.find(function(a) { return a.name == 'fedilove_age' }) diff --git a/src/scss/themes/ozark.scss b/src/scss/themes/ozark.scss index 85e762f4..2d4f16b4 100644 --- a/src/scss/themes/ozark.scss +++ b/src/scss/themes/ozark.scss @@ -150,6 +150,7 @@ body.chat { body.meet, body.account { height: 100%; overflow: hidden; + background: #222 !important; div#sapper, div.virtual-list, main.infinite-scroll-page { background: #222 !important; @@ -550,6 +551,11 @@ div.main-content.meet { main { padding: 0 !important; width: initial !important; + + div.timeline { + max-width: 90em; + margin: auto; + } } div.infinite-scroll-page { @@ -565,7 +571,7 @@ div.main-content.meet { position: fixed; top: 0 !important; width: 0; - max-width: 100em; + max-width: 90em; margin: auto; opacity: 1 !important; z-index: 0; diff --git a/static/fedilove-no-react.js b/static/fedilove-no-react.js index 961e9643..ccc9d5cc 100644 --- a/static/fedilove-no-react.js +++ b/static/fedilove-no-react.js @@ -234,6 +234,26 @@ var fediloveApi = { document.getElementById(_id).click(); document.body.removeChild(a); }, + getMeetAccount: function() { + if (window.localStorage.store_meetAccounts === undefined) + return undefined; + if (document.getElementById(window.fediloveData.currentIDMeetTimeline) === undefined) + return undefined; + var accId; + if (window.location.pathname == '/federated') + accId = $(document.getElementById(window.fediloveData.currentIDMeetTimeline)).data('account'); + else if (window.location.pathname.startsWith('/accounts/')) + accId = window.location.pathname.match(/^\/accounts\/(\d+)/)[1]; + if (accId === undefined) + return undefined; + const aJson = JSON.parse(window.localStorage.store_meetAccounts); + if (aJson[accId] === undefined) { + if (window.__store.get().currentAccountProfile === undefined) + return undefined; + return window.__store.get().currentAccountProfile; + } + return aJson[accId]; + }, getChatMessageId: function() { var parts = window.location.pathname.split('/'); return parts[parts.length-1]; @@ -279,8 +299,7 @@ var fediloveData = { meetAccountCurrentImg: 0, meetAccountImageLocked: false, myAccountId: undefined, - currentAccount: null, - currentAccouontIsEmpty: false, + currentAccountIsEmpty: false, currentIDMeetTimeline: null, gotEmojifyTextFunction: false, composeTxtKeypressEvent: false @@ -538,9 +557,10 @@ function fedilove_customization() { const _applyImageTo = function(selector) { setTimeout(function() { // set image of first item to the account header (100ms after cloning the object) - if (window.fediloveData.currentAccount != null) { + const accObj = window.fediloveApi.getMeetAccount(); + if (accObj !== undefined) { if ($(selector)[0] !== undefined) - $(selector)[0].src = window.fediloveData.currentAccount.header; + $(selector)[0].src = accObj.header; } }, 100); }; @@ -567,7 +587,7 @@ function fedilove_customization() { } clearInterval(_this); - } else if (fediloveData.currentAccountIsEmpty && window.fediloveData.currentAccount != null) { + } else if (fediloveData.currentAccountIsEmpty) { if ($('div.virtual-list > div.no-images-account').length === 0) $('div.virtual-list').append('
'); _applyImageTo('div.virtual-list > div.no-images-account > img.fixed-size-img');