Chat: do not load conversation twice

This commit is contained in:
Gautier Pelloux-Prayer 2015-11-18 11:27:55 +01:00
parent 602fe37b0f
commit 94dba3b493
7 changed files with 31 additions and 35 deletions

View file

@ -215,7 +215,7 @@
<animations/>
</imageView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="73" userLabel="pictureButton">
<rect key="frame" x="0.0" y="2" width="72" height="63"/>
<rect key="frame" x="0.0" y="2" width="63" height="63"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
<animations/>
<accessibility key="accessibilityConfiguration" label="Send picture"/>
@ -229,14 +229,14 @@
</connections>
</button>
<view contentMode="scaleToFill" id="pqa-tg-5ml" userLabel="messageField" customClass="HPGrowingTextView">
<rect key="frame" x="88" y="14" width="200" height="40"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<rect key="frame" x="71" y="14" width="233" height="40"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" flexibleMinY="YES" heightSizable="YES" flexibleMaxY="YES"/>
<animations/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<accessibility key="accessibilityConfiguration" label="Message field"/>
</view>
<button opaque="NO" contentMode="scaleToFill" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="15" userLabel="sendButton">
<rect key="frame" x="303" y="2" width="72" height="63"/>
<rect key="frame" x="312" y="2" width="63" height="63"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
<animations/>
<accessibility key="accessibilityConfiguration" label="Send"/>

View file

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7706" systemVersion="15B42" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="9059" systemVersion="15B42" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7703"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9049"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="ChatsListView">
@ -49,7 +49,7 @@
</connections>
</button>
<button hidden="YES" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="KhE-c3-2Zj" userLabel="cancelButton" customClass="UIIconButton">
<rect key="frame" x="0.0" y="1" width="75" height="63"/>
<rect key="frame" x="0.0" y="0.0" width="75" height="66"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" heightSizable="YES" flexibleMaxY="YES"/>
<animations/>
<accessibility key="accessibilityConfiguration" label="Delete all"/>
@ -65,7 +65,7 @@
</connections>
</button>
<button hidden="YES" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="Rxo-0W-iqY" userLabel="deleteButton" customClass="UIIconButton">
<rect key="frame" x="300" y="1" width="75" height="63"/>
<rect key="frame" x="300" y="0.0" width="75" height="66"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" heightSizable="YES" flexibleMaxY="YES"/>
<animations/>
<accessibility key="accessibilityConfiguration" label="Delete all"/>
@ -80,7 +80,7 @@
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="qem-Y1-v78" userLabel="editButton" customClass="UIIconButton">
<rect key="frame" x="300" y="1" width="75" height="63"/>
<rect key="frame" x="300" y="0.0" width="75" height="66"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" heightSizable="YES" flexibleMaxY="YES"/>
<animations/>
<accessibility key="accessibilityConfiguration" label="Edit"/>
@ -96,7 +96,7 @@
</connections>
</button>
<button hidden="YES" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="Fac-hy-za4" userLabel="backToCallButton" customClass="UIBackToCallButton">
<rect key="frame" x="225" y="1" width="75" height="63"/>
<rect key="frame" x="225" y="0.0" width="75" height="66"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" heightSizable="YES" flexibleMaxY="YES"/>
<animations/>
<state key="normal" image="call_back_default.png">
@ -187,9 +187,4 @@
<image name="select_all_default.png" width="26" height="26"/>
<image name="select_all_disabled.png" width="26" height="26"/>
</resources>
<simulatedMetricsContainer key="defaultSimulatedMetrics">
<simulatedStatusBarMetrics key="statusBar"/>
<simulatedOrientationMetrics key="orientation"/>
<simulatedScreenMetrics key="destination" type="retina4"/>
</simulatedMetricsContainer>
</document>

View file

@ -36,7 +36,8 @@
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
self.tableView.accessibilityIdentifier = @"ChatRoom list";
[self reloadData];
// this should not be needed, we should only load messages when setting the chat room
// [self reloadData];
}
#pragma mark -

View file

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7706" systemVersion="15B42" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="9059" systemVersion="15B42" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7703"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9049"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="UIChatCell">
@ -20,12 +20,12 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" image="avatar.png" id="19" userLabel="avatarImage" customClass="UIRoundedImageView">
<rect key="frame" x="8" y="2" width="46" height="44"/>
<rect key="frame" x="8" y="2" width="43" height="43"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<animations/>
</imageView>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" tag="2" contentMode="left" text="11:15" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="2" minimumFontSize="1" id="r7A-Mk-LQX" userLabel="chatLatestTimeLabel">
<rect key="frame" x="8" y="45" width="46" height="15"/>
<rect key="frame" x="8" y="45" width="43" height="15"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<animations/>
<accessibility key="accessibilityConfiguration" label=""/>
@ -34,7 +34,7 @@
<nil key="highlightedColor"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" tag="2" contentMode="left" text="John Doe" lineBreakMode="tailTruncation" minimumFontSize="10" adjustsFontSizeToFit="NO" id="20" userLabel="addressLabel">
<rect key="frame" x="63" y="0.0" width="271" height="31"/>
<rect key="frame" x="59" y="0.0" width="275" height="31"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<animations/>
<accessibility key="accessibilityConfiguration" label="Contact name"/>
@ -43,7 +43,7 @@
<nil key="highlightedColor"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" tag="2" contentMode="left" text="This is a placeholder message" lineBreakMode="tailTruncation" numberOfLines="3" adjustsFontSizeToFit="NO" id="21" userLabel="chatContentLabel">
<rect key="frame" x="63" y="31" width="312" height="29"/>
<rect key="frame" x="59" y="31" width="316" height="29"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxX="YES" flexibleMinY="YES" heightSizable="YES"/>
<animations/>
<accessibility key="accessibilityConfiguration" label="Message"/>
@ -56,7 +56,7 @@
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
<animations/>
<accessibility key="accessibilityConfiguration" label="Unread message count">
<accessibilityTraits key="traits" none="YES" staticText="YES" notEnabled="YES"/>
<accessibilityTraits key="traits" staticText="YES" notEnabled="YES"/>
</accessibility>
<state key="normal" title="0" backgroundImage="chat_list_indicator.png">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
@ -66,16 +66,11 @@
<animations/>
<nil key="simulatedStatusBarMetrics"/>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<point key="canvasLocation" x="157" y="240"/>
<point key="canvasLocation" x="156.5" y="240"/>
</view>
</objects>
<resources>
<image name="avatar.png" width="255" height="255"/>
<image name="chat_list_indicator.png" width="20" height="20"/>
</resources>
<simulatedMetricsContainer key="defaultSimulatedMetrics">
<simulatedStatusBarMetrics key="statusBar"/>
<simulatedOrientationMetrics key="orientation"/>
<simulatedScreenMetrics key="destination" type="retina4"/>
</simulatedMetricsContainer>
</document>

View file

@ -127,7 +127,8 @@
if (outgoing && state == LinphoneChatMessageStateInProgress) {
_statusErrorImage.hidden = YES;
[_statusInProgressSpinner startAnimating];
} else if (outgoing && state != LinphoneChatMessageStateDelivered) {
} else if (outgoing &&
(state == LinphoneChatMessageStateNotDelivered || state == LinphoneChatMessageStateFileTransferError)) {
_statusErrorImage.hidden = NO;
[_statusInProgressSpinner stopAnimating];
@ -135,6 +136,9 @@
[[NSAttributedString alloc] initWithString:NSLocalizedString(@"Resend", @"Resend")
attributes:@{NSForegroundColorAttributeName : [UIColor redColor]}];
[_contactDateLabel setAttributedText:resend_text];
} else if (!outgoing && state == LinphoneChatMessageStateFileTransferError) {
_statusErrorImage.hidden = NO;
[_statusInProgressSpinner stopAnimating];
} else {
_statusErrorImage.hidden = YES;
[_statusInProgressSpinner stopAnimating];
@ -169,7 +173,7 @@
}
- (IBAction)onResendClick:(id)event {
if (_message == nil)
if (_message == nil || !linphone_chat_message_is_outgoing(_message))
return;
LinphoneChatMessageState state = linphone_chat_message_get_state(_message);
@ -232,7 +236,7 @@ static void message_status(LinphoneChatMessage *msg, LinphoneChatMessageState st
static const CGFloat CELL_MIN_HEIGHT = 60.0f;
static const CGFloat CELL_MIN_WIDTH = 150.0f;
static const CGFloat CELL_MESSAGE_X_MARGIN = 72 + 10.0f;
static const CGFloat CELL_MESSAGE_X_MARGIN = 78 + 10.0f;
static const CGFloat CELL_MESSAGE_Y_MARGIN = 32;
static const CGFloat CELL_IMAGE_HEIGHT = 100.0f;
static const CGFloat CELL_IMAGE_WIDTH = 100.0f;
@ -298,13 +302,14 @@ static const CGFloat CELL_IMAGE_WIDTH = 100.0f;
int available_width = self.frame.size.width;
int origin_x;
bubbleFrame.size = [self.class ViewSizeForMessage:_message withWidth:available_width];
if (tableView.isEditing) {
origin_x = 0;
} else {
origin_x = (is_outgoing ? self.frame.size.width - bubbleFrame.size.width : 0);
}
bubbleFrame.size = [self.class ViewSizeForMessage:_message withWidth:available_width];
bubbleFrame.origin.x = origin_x;
_bubbleView.frame = bubbleFrame;
}

View file

@ -56,7 +56,7 @@
<nil key="highlightedColor"/>
</label>
<textView clipsSubviews="YES" contentMode="scaleToFill" scrollEnabled="NO" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" editable="NO" text="Lore ipsum..." id="CYa-If-oB4" userLabel="messageText" customClass="UITextViewNoDefine">
<rect key="frame" x="48" y="7" width="280" height="54"/>
<rect key="frame" x="48" y="7" width="274" height="54"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxX="YES" heightSizable="YES" flexibleMaxY="YES"/>
<animations/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>

@ -1 +1 @@
Subproject commit 8c2a440fd9804ea3dacd27737afd3f18911e0379
Subproject commit 91352ffccd1edba32f56794194b0cc2695acd387