Open active stream controls from any Android header
This commit is contained in:
1 parent
59858a726a
commit
d7053a2366
2 files changed
+25
-1
No files matched your search
@@ -57,6 +57,7 @@ import com.utun.chat.data.Channel
|
||||
import com.utun.chat.data.IncomingCallManager
|
||||
import com.utun.chat.data.InviteData
|
||||
import com.utun.chat.data.LogManager
|
||||
import com.utun.chat.data.StreamController
|
||||
import com.utun.chat.data.Message
|
||||
import com.utun.chat.data.ConversationTarget
|
||||
import com.utun.chat.data.NativeLib
|
||||
@@ -247,6 +248,27 @@ class MainActivity : AppCompatActivity() {
|
||||
var screenBeforeCall by rememberSaveable { mutableStateOf<Screen?>(null) }
|
||||
val snackbarHostState = remember { SnackbarHostState() }
|
||||
val scope = rememberCoroutineScope()
|
||||
val openOwnStream: (Long) -> Unit = openOwnStream@{ group ->
|
||||
val publisher = StreamController.state.value
|
||||
if (publisher?.ongoing != true || publisher.group != group) {
|
||||
LogManager.addLog("WARN", "stream", "own stream navigation stale group=$group publisher=${publisher?.id}")
|
||||
return@openOwnStream
|
||||
}
|
||||
val channel = vm.channels.value.firstOrNull { it.id == group.toULong().toString() }
|
||||
if (channel == null) {
|
||||
LogManager.addLog("ERROR", "stream", "own stream channel unavailable group=$group publisher=${publisher.id}")
|
||||
scope.launch { snackbarHostState.showSnackbar(getString(R.string.stream_group_closed)) }
|
||||
return@openOwnStream
|
||||
}
|
||||
LogManager.addLog("INFO", "stream", "own stream navigation from=$screen channel=${vm.currentChannel.value?.id} " +
|
||||
"target=${channel.id} publisher=${publisher.id}")
|
||||
if (vm.currentChannel.value?.id != channel.id) vm.selectChannel(channel)
|
||||
if (vm.currentChannel.value?.id != channel.id) {
|
||||
LogManager.addLog("ERROR", "stream", "own stream channel selection failed group=$group")
|
||||
return@openOwnStream
|
||||
}
|
||||
vm.selectStream(null); screen = Screen.Streams
|
||||
}
|
||||
val pmInvite by vm.pmInvite.collectAsState()
|
||||
val linkJoin by vm.linkJoin.collectAsState()
|
||||
val joinedChannel by vm.joinedChannel.collectAsState()
|
||||
@@ -401,6 +423,7 @@ class MainActivity : AppCompatActivity() {
|
||||
onDeleteChannel = { vm.deleteChannel(it.id) },
|
||||
onSettings = { screen = Screen.Settings },
|
||||
onLogs = { screen = Screen.Logs },
|
||||
onOwnStream = openOwnStream,
|
||||
onRefresh = { vm.requestRefresh() }
|
||||
)
|
||||
}
|
||||
@@ -420,6 +443,7 @@ class MainActivity : AppCompatActivity() {
|
||||
onInvite = { showInvite(channel) },
|
||||
onBack = { screen = Screen.ChannelList },
|
||||
onStreams = { vm.selectStream(null); screen = Screen.Streams },
|
||||
onOwnStream = openOwnStream,
|
||||
onWatchStream = { vm.selectStream(it); screen = Screen.Streams },
|
||||
onWatchAllStreams = { vm.watchAllStreams(); screen = Screen.Streams },
|
||||
onPlayVideo = { msg -> videoMessage = msg },
|
||||
|
||||
@@ -561,7 +561,7 @@ MessageList::MessageList(DbManager* db, AudioRecorder* recorder, QWidget *parent
|
||||
if (!channel.toULongLong()) return;
|
||||
auto text = [](const char* s) { return QCoreApplication::translate("ChatGui", s); };
|
||||
QMenu menu(this);
|
||||
const bool own = m_streamPublisherGroup && m_streamPublisherGroup == channel.toULongLong();
|
||||
const bool own = m_streamPublisherGroup != 0;
|
||||
auto* publish = menu.addAction(text(own ? "Manage stream" : "Start stream"));
|
||||
menu.addSeparator();
|
||||
auto* files = menu.addAction(text("Group files"));
|
||||
|
||||
Reference in new issue
Block a user