Ejemplo n.º 1
0
        private async void UserInputBar_OnSendMessageButtonClicked()
        {
            if (string.IsNullOrEmpty(UserInputBar.InputText) && SelectedFile == null)
            {
                var filePicker = new FileOpenPicker();
                filePicker.FileTypeFilter.Add("*"); // Without this the file picker throws an exception, this is not documented
                SelectedFile = await filePicker.PickSingleFileAsync();

                if (SelectedFile != null)
                {
                    AddedAttachmentDisplay.ShowAttachment(SelectedFile.Name);
                    UpdateSendButtonIcon();
                    UserInputBar.FocusTextBox();
                }
                else
                {
                    AddedAttachmentDisplay.HideAttachment();
                }
            }
            else
            {
                bool sendMessageResult = await GetMainPageVm().SendMessage(UserInputBar.InputText, SelectedFile);

                if (sendMessageResult)
                {
                    ResetInput();
                }
            }
        }
        public void Load(SignalConversation conversation)
        {
            bool conversationThreadIdChanged = SignalConversation?.ThreadId != conversation?.ThreadId;

            SignalConversation = conversation;
            if (SignalConversation is SignalContact contact)
            {
                Blocked            = contact.Blocked;
                SendMessageVisible = !Blocked;
            }
            else
            {
                // Need to make sure to reset the Blocked and SendMessageVisible values in case
                // a group chat is selected. Group chats can never be blocked.
                Blocked            = false;
                SendMessageVisible = !Blocked;
            }
            LastMarkReadRequest = -1;
            SendButtonEnabled   = false;

            /*
             * On app resume this method (Load()) gets called with the same conversation, but new object.
             * Only load draft if it is acutally a different conversation,
             * because on mobile app gets supended during file picking and
             * the new conversation does not have the DraftFileTokens
             */
            if (conversationThreadIdChanged)
            {
                // We don't need to wait for this
                _ = LoadDraft();
            }
            UserInputBar.FocusTextBox();
            DisposeCurrentThread();
            UpdateHeader(conversation);
            SpellCheckEnabled = GlobalSettingsManager.SpellCheckSetting;

            /*
             * When selecting a small (~650 messages) conversation after a bigger (~1800 messages) one,
             * ScrollToBottom would scroll so far south that the entire screen was white. Seems like the
             * scrollbar is not properly notified that the collection changed. I tried things like throwing
             * CollectionChanged (reset) event, but to no avail. This hack works, though.
             */
            ConversationItemsControl.ItemsSource = new List <object>();
            UpdateLayout();
            Collection = new VirtualizedCollection(conversation);
            ConversationItemsControl.ItemsSource = Collection;
            UpdateLayout();
            SendButtonEnabled = conversation.CanReceive;
            ScrollToUnread();
        }
Ejemplo n.º 3
0
        public void Load(SignalConversation conversation)
        {
            SignalConversation = conversation;
            if (SignalConversation is SignalContact contact)
            {
                Blocked            = contact.Blocked;
                SendMessageVisible = !Blocked;
            }
            else
            {
                // Need to make sure to reset the Blocked and SendMessageVisible values in case
                // a group chat is selected. Group chats can never be blocked.
                Blocked            = false;
                SendMessageVisible = !Blocked;
            }
            LastMarkReadRequest = -1;
            SendButtonEnabled   = false;
            ResetInput();
            UserInputBar.FocusTextBox();
            DisposeCurrentThread();
            UpdateHeader(conversation);
            SpellCheckEnabled = GlobalSettingsManager.SpellCheckSetting;

            /*
             * When selecting a small (~650 messages) conversation after a bigger (~1800 messages) one,
             * ScrollToBottom would scroll so far south that the entire screen was white. Seems like the
             * scrollbar is not properly notified that the collection changed. I tried things like throwing
             * CollectionChanged (reset) event, but to no avail. This hack works, though.
             */
            ConversationItemsControl.ItemsSource = new List <object>();
            UpdateLayout();
            Collection = new VirtualizedCollection(conversation);
            ConversationItemsControl.ItemsSource = Collection;
            UpdateLayout();
            SendButtonEnabled = conversation.CanReceive;
            ScrollToUnread();
        }