Skip to content
This repository has been archived by the owner on Feb 22, 2020. It is now read-only.

Commit

Permalink
reconnection bug fixes
Browse files Browse the repository at this point in the history
fixed bugs concerning reconnection and uialertviews not showing when they're supposed to
  • Loading branch information
trev3d committed Dec 28, 2018
1 parent d2bedc1 commit adfcc9c
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 24 deletions.
Binary file not shown.
2 changes: 0 additions & 2 deletions Discord Classic/DCChatTableCell.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,4 @@
@property (strong, nonatomic) IBOutlet UILabel *authorLabel;
@property (weak, nonatomic) IBOutlet UIImageView *profileImage;
@property (strong, nonatomic) IBOutlet UITextView *contentTextView;

-(void)layoutSubviews;
@end
20 changes: 8 additions & 12 deletions Discord Classic/DCServerCommunicator.m
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ + (DCServerCommunicator *)sharedInstance {

- (void)startCommunicator{

[self.alertView show];

self.didAuthenticate = false;

if(self.token!=nil){
Expand Down Expand Up @@ -82,11 +84,6 @@ - (void)startCommunicator{
case 10: {

if(weakSelf.shouldResume){

dispatch_async(dispatch_get_main_queue(), ^{
[weakSelf.alertView setTitle:@"Resuming"];
});

NSLog(@"Sending Resume with sequence number %i, session ID %@", weakSelf.sequenceNumber, weakSelf.sessionId);

//RESUME
Expand All @@ -105,10 +102,6 @@ - (void)startCommunicator{

NSLog(@"Sending Identify");

dispatch_async(dispatch_get_main_queue(), ^{
[weakSelf.alertView setTitle:@"Authenticating"];
});

//IDENTIFY
[weakSelf sendJSON:@{
@"op":@2,
Expand Down Expand Up @@ -246,10 +239,12 @@ - (void)startCommunicator{
});
}

if([t isEqualToString:@"RESUMED"])
if([t isEqualToString:@"RESUMED"]){
weakSelf.didAuthenticate = true;
dispatch_async(dispatch_get_main_queue(), ^{
[weakSelf.alertView dismissWithClickedButtonIndex:0 animated:YES];
});
}

if([t isEqualToString:@"MESSAGE_CREATE"]){

Expand Down Expand Up @@ -320,6 +315,8 @@ - (void)startCommunicator{


- (void)sendResume{
[self.alertView setTitle:@"Resuming"];

self.shouldResume = true;
[self startCommunicator];
}
Expand All @@ -328,8 +325,6 @@ - (void)sendResume{

- (void)reconnect{

[self.alertView show];

NSLog(@"Identify cooldown %s", self.identifyCooldown ? "true" : "false");

//Begin new session
Expand All @@ -339,6 +334,7 @@ - (void)reconnect{
//if not, send immediately
if(self.identifyCooldown){
NSLog(@"No cooldown in effect. Authenticating...");
[self.alertView setTitle:@"Authenticating"];
[self startCommunicator];
}else{
double timeRemaining = self.cooldownTimer.fireDate.timeIntervalSinceNow;
Expand Down
54 changes: 44 additions & 10 deletions Storyboard.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="aFs-Iw-A4I" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-126" y="504"/>
<point key="canvasLocation" x="544" y="524"/>
</scene>
<!--Settings View Controller - Settings-->
<scene sceneID="qbG-hh-URF">
Expand Down Expand Up @@ -439,6 +439,11 @@
</tableView>
<navigationItem key="navigationItem" title="Channels" id="8HN-UR-APC">
<barButtonItem key="backBarButtonItem" title="Servers" id="g0Z-SR-CoJ"/>
<barButtonItem key="rightBarButtonItem" title="Members" id="TDg-OD-kjq">
<connections>
<segue destination="PXD-U7-aFj" kind="push" id="37H-hE-Yz2"/>
</connections>
</barButtonItem>
</navigationItem>
<connections>
<segue destination="SPS-Go-Xtj" kind="push" identifier="Channels to Chat" id="VzJ-bP-Mkv"/>
Expand Down Expand Up @@ -503,6 +508,11 @@
</view>
<navigationItem key="navigationItem" id="VOY-oz-qxj">
<barButtonItem key="backBarButtonItem" title="Channels" id="Or6-sa-oea"/>
<barButtonItem key="rightBarButtonItem" title="Members" id="Bbo-U1-qTl">
<connections>
<segue destination="PXD-U7-aFj" kind="push" id="l0E-1x-536"/>
</connections>
</barButtonItem>
</navigationItem>
<connections>
<outlet property="chatTableView" destination="FQU-uE-jCg" id="Zu3-NK-RP6"/>
Expand All @@ -524,6 +534,36 @@
</objects>
<point key="canvasLocation" x="1089" y="-87"/>
</scene>
<!--Table View Controller - Members-->
<scene sceneID="XQc-ZO-D2E">
<objects>
<tableViewController id="PXD-U7-aFj" sceneMemberID="viewController">
<tableView key="view" opaque="NO" clipsSubviews="YES" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" id="HNs-ae-d0L">
<rect key="frame" x="0.0" y="64" width="320" height="416"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<prototypes>
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" id="siI-CZ-BbX">
<rect key="frame" x="0.0" y="22" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
<rect key="frame" x="0.0" y="0.0" width="320" height="43"/>
<autoresizingMask key="autoresizingMask"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</view>
</tableViewCell>
</prototypes>
<connections>
<outlet property="dataSource" destination="PXD-U7-aFj" id="D0A-6f-Baf"/>
<outlet property="delegate" destination="PXD-U7-aFj" id="jCQ-qn-tSj"/>
</connections>
</tableView>
<navigationItem key="navigationItem" title="Members" id="fRC-Fn-SEq"/>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="fEM-tZ-UX7" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1635" y="524"/>
</scene>
<!--Image View Controller-->
<scene sceneID="f9C-bg-NlD">
<objects>
Expand Down Expand Up @@ -559,7 +599,7 @@
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="a7p-Nr-Niu" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1511" y="-87"/>
<point key="canvasLocation" x="1635" y="-87"/>
</scene>
</scenes>
<classes>
Expand All @@ -572,23 +612,17 @@
<class className="DCChatViewController" superclassName="UIViewController">
<source key="sourceIdentifier" type="project" relativePath="./Classes/DCChatViewController.h"/>
<relationships>
<relationship kind="action" name="chooseImage:"/>
<relationship kind="action" name="sendMessage:"/>
<relationship kind="outlet" name="chatTableView" candidateClass="UITableView"/>
<relationship kind="outlet" name="inputField" candidateClass="UITextField"/>
<relationship kind="outlet" name="toolbar" candidateClass="UIToolbar"/>
</relationships>
</class>
<class className="DCGuildListViewController" superclassName="UITableViewController">
<source key="sourceIdentifier" type="project" relativePath="./Classes/DCGuildListViewController.h"/>
<relationships>
<relationship kind="action" name="joinGuildPrompt:"/>
</relationships>
</class>
<class className="DCImageViewController" superclassName="UIViewController">
<source key="sourceIdentifier" type="project" relativePath="./Classes/DCImageViewController.h"/>
<relationships>
<relationship kind="action" name="presentShareSheet:"/>
<relationship kind="outlet" name="imageView" candidateClass="UIImageView"/>
<relationship kind="outlet" name="scrollView" candidateClass="UIScrollView"/>
</relationships>
Expand All @@ -599,7 +633,6 @@
<class className="DCSettingsViewController" superclassName="UITableViewController">
<source key="sourceIdentifier" type="project" relativePath="./Classes/DCSettingsViewController.h"/>
<relationships>
<relationship kind="action" name="openTutorial:"/>
<relationship kind="outlet" name="tokenInputField" candidateClass="UITextField"/>
</relationships>
</class>
Expand All @@ -613,6 +646,7 @@
<simulatedScreenMetrics key="destination"/>
</simulatedMetricsContainer>
<inferredMetricsTieBreakers>
<segue reference="fcm-4D-Lhj"/>
<segue reference="l0E-1x-536"/>
<segue reference="VzJ-bP-Mkv"/>
</inferredMetricsTieBreakers>
</document>

0 comments on commit adfcc9c

Please sign in to comment.