Dynamicaly update/blank-out "Send" softkey
I perhaps spent an inordinate amount of time getting this to work to my satisfaction :P
This commit is contained in:
parent
ca92f79d7a
commit
cf926cd5b6
1 changed files with 45 additions and 8 deletions
|
@ -15,7 +15,7 @@
|
|||
|
||||
export let params = {}
|
||||
let title
|
||||
let centerSoftkeyLabel = 'Send'
|
||||
let centerSoftkeyLabel = ' '
|
||||
let chatbox
|
||||
let messages
|
||||
let chatListEl
|
||||
|
@ -77,12 +77,6 @@
|
|||
return k
|
||||
})
|
||||
|
||||
$: softkeysStore.update((k) => {
|
||||
k.center.label = centerSoftkeyLabel
|
||||
|
||||
return k
|
||||
})
|
||||
|
||||
// Run this and unsubscribe after one
|
||||
// second. (The xmppConnected.subscribe function
|
||||
// returns the unsubscribe callback, which we
|
||||
|
@ -93,11 +87,54 @@
|
|||
}
|
||||
}), 1000)
|
||||
|
||||
// Manage the compose box
|
||||
|
||||
function onComposeBoxFocus() {
|
||||
// scroll to last message, for convenience
|
||||
scrollToLatest()
|
||||
|
||||
if (!!composeBox) {
|
||||
centerSoftkeyLabel = 'Send'
|
||||
} else {
|
||||
centerSoftkeyLabel = ' '
|
||||
}
|
||||
}
|
||||
|
||||
function updateCenterSoftkeyLabel() {
|
||||
softkeysStore.update((k) => {
|
||||
k.center.label = centerSoftkeyLabel
|
||||
|
||||
return k
|
||||
})
|
||||
}
|
||||
|
||||
function updateComposeLabel() {
|
||||
// We're using 'Send' as a proxy for
|
||||
// checking if the box is focused
|
||||
if (!composeBox && centerSoftkeyLabel == 'Send') {
|
||||
centerSoftkeyLabel = ' ' // hack
|
||||
|
||||
// We have to do this since reactivity
|
||||
// doesn't recurse
|
||||
updateCenterSoftkeyLabel()
|
||||
} else if (!!composeBox && centerSoftkeyLabel == ' ') {
|
||||
centerSoftkeyLabel = 'Send'
|
||||
|
||||
// We have to do this since reactivity
|
||||
// doesn't recurse
|
||||
updateCenterSoftkeyLabel()
|
||||
}
|
||||
}
|
||||
|
||||
$: softkeysStore.update((k) => {
|
||||
k.center.label = centerSoftkeyLabel
|
||||
|
||||
return k
|
||||
})
|
||||
|
||||
$: {
|
||||
!composeBox // whenever this changes
|
||||
updateComposeLabel()
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
|
|
Loading…
Reference in a new issue