instead of filtering nulls, let's just not have them in the first place

This commit is contained in:
Henry Jameson 2019-03-11 23:03:55 +02:00
parent 06d39b62a8
commit a6a162177b
2 changed files with 10 additions and 11 deletions

View file

@ -1,5 +1,5 @@
import backendInteractorService from '../services/backend_interactor_service/backend_interactor_service.js' import backendInteractorService from '../services/backend_interactor_service/backend_interactor_service.js'
import { compact, map, each, merge, find, omitBy } from 'lodash' import { compact, map, each, merge, find } from 'lodash'
import { set } from 'vue' import { set } from 'vue'
import { registerPushNotifications, unregisterPushNotifications } from '../services/push/push.js' import { registerPushNotifications, unregisterPushNotifications } from '../services/push/push.js'
import oauthApi from '../services/new_api/oauth' import oauthApi from '../services/new_api/oauth'
@ -11,7 +11,7 @@ export const mergeOrAdd = (arr, obj, item) => {
const oldItem = obj[item.id] const oldItem = obj[item.id]
if (oldItem) { if (oldItem) {
// We already have this, so only merge the new info. // We already have this, so only merge the new info.
merge(oldItem, omitBy(item, _ => _ === null)) merge(oldItem, item)
return { item: oldItem, new: false } return { item: oldItem, new: false }
} else { } else {
// This is a new item, prepare it // This is a new item, prepare it
@ -39,7 +39,7 @@ export const mutations = {
}, },
setCurrentUser (state, user) { setCurrentUser (state, user) {
state.lastLoginName = user.screen_name state.lastLoginName = user.screen_name
state.currentUser = merge(state.currentUser || {}, omitBy(user, _ => _ === null)) state.currentUser = merge(state.currentUser || {}, user)
}, },
clearCurrentUser (state) { clearCurrentUser (state) {
state.currentUser = false state.currentUser = false

View file

@ -39,10 +39,10 @@ export const parseUser = (data) => {
return output return output
} }
output.name = null // missing // output.name = ??? missing
output.name_html = data.display_name output.name_html = data.display_name
output.description = null // missing // output.description = ??? missing
output.description_html = data.note output.description_html = data.note
// Utilize avatar_static for gif avatars? // Utilize avatar_static for gif avatars?
@ -83,7 +83,7 @@ export const parseUser = (data) => {
output.friends_count = data.friends_count output.friends_count = data.friends_count
output.bot = null // missing // output.bot = ??? missing
output.statusnet_profile_url = data.statusnet_profile_url output.statusnet_profile_url = data.statusnet_profile_url
@ -134,7 +134,7 @@ const parseAttachment = (data) => {
output.meta = data.meta // not present in BE yet output.meta = data.meta // not present in BE yet
} else { } else {
output.mimetype = data.mimetype output.mimetype = data.mimetype
output.meta = null // missing // output.meta = ??? missing
} }
output.url = data.url output.url = data.url
@ -166,7 +166,7 @@ export const parseStatus = (data) => {
output.in_reply_to_user_id = data.in_reply_to_account_id output.in_reply_to_user_id = data.in_reply_to_account_id
// Missing!! fix in UI? // Missing!! fix in UI?
output.in_reply_to_screen_name = null // output.in_reply_to_screen_name = ???
// Not exactly the same but works // Not exactly the same but works
output.statusnet_conversation_id = data.id output.statusnet_conversation_id = data.id
@ -179,8 +179,7 @@ export const parseStatus = (data) => {
output.summary_html = data.spoiler_text output.summary_html = data.spoiler_text
output.external_url = data.url output.external_url = data.url
// FIXME missing!! // output.is_local = ??? missing
output.is_local = false
} else { } else {
output.favorited = data.favorited output.favorited = data.favorited
output.fave_num = data.fave_num output.fave_num = data.fave_num
@ -259,7 +258,7 @@ export const parseNotification = (data) => {
if (masto) { if (masto) {
output.type = mastoDict[data.type] || data.type output.type = mastoDict[data.type] || data.type
output.seen = null // missing // output.seen = ??? missing
output.status = parseStatus(data.status) output.status = parseStatus(data.status)
output.action = output.status // not sure output.action = output.status // not sure
output.from_profile = parseUser(data.account) output.from_profile = parseUser(data.account)