diff options
| author | Shpuld Shpludson <shp@cock.li> | 2021-03-01 18:15:46 +0000 |
|---|---|---|
| committer | Shpuld Shpludson <shp@cock.li> | 2021-03-01 18:15:46 +0000 |
| commit | c3fcbbd918ddef4e3f574a464fd10f4899bb2dce (patch) | |
| tree | 695ccbd352c82cb0f08fc78ff85bf23888561a8e /src/services | |
| parent | 320418d524a33c20d7d769c8d67a25be81f251ec (diff) | |
| parent | 0ac34b3014a1499ef5f3de7d3c321119dd10ab26 (diff) | |
Merge branch 'rc/2.3.0' into 'master'
2.3.0 to MASTER
See merge request pleroma/pleroma-fe!1366
Diffstat (limited to 'src/services')
| -rw-r--r-- | src/services/chat_service/chat_service.js | 17 | ||||
| -rw-r--r-- | src/services/entity_normalizer/entity_normalizer.service.js | 12 | ||||
| -rw-r--r-- | src/services/locale/locale.service.js | 12 | ||||
| -rw-r--r-- | src/services/style_setter/style_setter.js | 15 |
4 files changed, 50 insertions, 6 deletions
diff --git a/src/services/chat_service/chat_service.js b/src/services/chat_service/chat_service.js index e653ebc1..92ff689d 100644 --- a/src/services/chat_service/chat_service.js +++ b/src/services/chat_service/chat_service.js @@ -48,6 +48,22 @@ const deleteMessage = (storage, messageId) => { } } +const cullOlderMessages = (storage) => { + const maxIndex = storage.messages.length + const minIndex = maxIndex - 50 + if (maxIndex <= 50) return + + storage.messages = _.sortBy(storage.messages, ['id']) + storage.minId = storage.messages[minIndex].id + for (const message of storage.messages) { + if (message.id < storage.minId) { + delete storage.idIndex[message.id] + delete storage.idempotencyKeyIndex[message.idempotency_key] + } + } + storage.messages = storage.messages.slice(minIndex, maxIndex) +} + const handleMessageError = (storage, fakeId, isRetry) => { if (!storage) { return } const fakeMessage = storage.idIndex[fakeId] @@ -201,6 +217,7 @@ const ChatService = { empty, getView, deleteMessage, + cullOlderMessages, resetNewMessageCount, clear, handleMessageError diff --git a/src/services/entity_normalizer/entity_normalizer.service.js b/src/services/entity_normalizer/entity_normalizer.service.js index 625f593e..9b2b30e6 100644 --- a/src/services/entity_normalizer/entity_normalizer.service.js +++ b/src/services/entity_normalizer/entity_normalizer.service.js @@ -188,7 +188,12 @@ export const parseUser = (data) => { output.follow_request_count = data.pleroma.follow_request_count output.tags = data.pleroma.tags - output.deactivated = data.pleroma.deactivated + + // deactivated was changed to is_active in Pleroma 2.3.0 + // so check if is_active is present + output.deactivated = typeof data.pleroma.is_active !== 'undefined' + ? !data.pleroma.is_active // new backend + : data.pleroma.deactivated // old backend output.notification_settings = data.pleroma.notification_settings output.unread_chat_count = data.pleroma.unread_chat_count @@ -198,7 +203,8 @@ export const parseUser = (data) => { output.rights = output.rights || {} output.notification_settings = output.notification_settings || {} - // Convert punycode to unicode + // Convert punycode to unicode for UI + output.screen_name_ui = output.screen_name if (output.screen_name.includes('@')) { const parts = output.screen_name.split('@') let unicodeDomain = punycode.toUnicode(parts[1]) @@ -206,7 +212,7 @@ export const parseUser = (data) => { // Add some identifier so users can potentially spot spoofing attempts: // lain.com and xn--lin-6cd.com would appear identical otherwise. unicodeDomain = '🌏' + unicodeDomain - output.screen_name = [parts[0], unicodeDomain].join('@') + output.screen_name_ui = [parts[0], unicodeDomain].join('@') } } diff --git a/src/services/locale/locale.service.js b/src/services/locale/locale.service.js new file mode 100644 index 00000000..5be99d81 --- /dev/null +++ b/src/services/locale/locale.service.js @@ -0,0 +1,12 @@ +const specialLanguageCodes = { + 'ja_easy': 'ja', + 'zh_Hant': 'zh-HANT' +} + +const internalToBrowserLocale = code => specialLanguageCodes[code] || code + +const localeService = { + internalToBrowserLocale +} + +export default localeService diff --git a/src/services/style_setter/style_setter.js b/src/services/style_setter/style_setter.js index 07425abd..a2bba67b 100644 --- a/src/services/style_setter/style_setter.js +++ b/src/services/style_setter/style_setter.js @@ -242,9 +242,18 @@ export const generateShadows = (input, colors) => { panelHeader: 'panel', input: 'input' } - const inputShadows = input.shadows && !input.themeEngineVersion - ? shadows2to3(input.shadows, input.opacity) - : input.shadows || {} + + const cleanInputShadows = Object.fromEntries( + Object.entries(input.shadows || {}) + .map(([name, shadowSlot]) => [ + name, + // defaulting color to black to avoid potential problems + shadowSlot.map(shadowDef => ({ color: '#000000', ...shadowDef })) + ]) + ) + const inputShadows = cleanInputShadows && !input.themeEngineVersion + ? shadows2to3(cleanInputShadows, input.opacity) + : cleanInputShadows || {} const shadows = Object.entries({ ...DEFAULT_SHADOWS, ...inputShadows |
