Skip to content

Commit 6d1cf01

Browse files
committed
Merge branch 'release/1.8.12/master'
2 parents 1e99e19 + 6213bae commit 6d1cf01

File tree

11 files changed

+144
-43
lines changed

11 files changed

+144
-43
lines changed

CHANGES.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## Changes in 1.8.12 (2022-04-06)
2+
3+
🐛 Bugfixes
4+
5+
- RecentsViewController: Room context preview dismissed unexpectedly ([#5992](https://github.com/vector-im/element-ios/issues/5992))
6+
- Notifications: Strings now fall back to English if they're missing for the current language. ([#5996](https://github.com/vector-im/element-ios/issues/5996))
7+
8+
19
## Changes in 1.8.11 (2022-04-05)
210

311
✨ Features

Config/AppVersion.xcconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@
1515
//
1616

1717
// Version
18-
MARKETING_VERSION = 1.8.11
19-
CURRENT_PROJECT_VERSION = 1.8.11
18+
MARKETING_VERSION = 1.8.12
19+
CURRENT_PROJECT_VERSION = 1.8.12

Riot/Categories/Bundle.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import Foundation
1919
public extension Bundle {
2020
/// Returns the real app bundle.
2121
/// Can also be used in app extensions.
22-
static var app: Bundle {
22+
@objc static var app: Bundle {
2323
let bundle = main
2424
if bundle.bundleURL.pathExtension == "appex" {
2525
// Peel off two directory levels - MY_APP.app/PlugIns/MY_APP_EXTENSION.appex
@@ -31,6 +31,14 @@ public extension Bundle {
3131
return bundle
3232
}
3333

34+
/// Get an lproj language bundle from the main app bundle.
35+
/// - Parameter language: The language to try to load.
36+
/// - Returns: The lproj bundle if found otherwise `nil`.
37+
@objc static func lprojBundle(for language: String) -> Bundle? {
38+
guard let lprojURL = Bundle.app.url(forResource: language, withExtension: "lproj") else { return nil }
39+
return Bundle(url: lprojURL)
40+
}
41+
3442
/// Whether or not the bundle is the RiotShareExtension.
3543
var isShareExtension: Bool {
3644
bundleURL.lastPathComponent.contains("RiotShareExtension.appex")

Riot/Generated/Strings.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8006,7 +8006,7 @@ public class VectorL10n: NSObject {
80068006

80078007
extension VectorL10n {
80088008
static func tr(_ table: String, _ key: String, _ args: CVarArg...) -> String {
8009-
let format = NSLocalizedString(key, tableName: table, bundle: Bundle(for: BundleToken.self), comment: "")
8009+
let format = NSLocalizedString(key, tableName: table, bundle: Bundle.app, comment: "")
80108010
let locale: Locale
80118011
if let providedLocale = LocaleProvider.locale {
80128012
locale = providedLocale
@@ -8018,4 +8018,3 @@ extension VectorL10n {
80188018
}
80198019
}
80208020

8021-
private final class BundleToken {}

Riot/Modules/Common/Recents/RecentsViewController.m

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,14 @@ - (void)viewDidLayoutSubviews
366366

367367
- (void)refreshRecentsTable
368368
{
369+
if (!self.recentsUpdateEnabled)
370+
{
371+
isRefreshNeeded = NO;
372+
return;
373+
}
374+
375+
isRefreshNeeded = NO;
376+
369377
// Refresh the tabBar icon badges
370378
[[AppDelegate theDelegate].masterTabBarController refreshTabBarBadges];
371379

@@ -1034,6 +1042,12 @@ - (void)dataSource:(MXKDataSource *)dataSource didRecognizeAction:(NSString *)ac
10341042

10351043
- (void)dataSource:(MXKDataSource *)dataSource didCellChange:(id)changes
10361044
{
1045+
if (!self.recentsUpdateEnabled)
1046+
{
1047+
[super dataSource:dataSource didCellChange:changes];
1048+
return;
1049+
}
1050+
10371051
BOOL cellReloaded = NO;
10381052
if ([changes isKindOfClass:RecentsSectionUpdate.class])
10391053
{
@@ -2502,6 +2516,7 @@ - (UIContextMenuConfiguration *)tableView:(UITableView *)tableView contextMenuCo
25022516
return nil;
25032517
}
25042518

2519+
self.recentsUpdateEnabled = NO;
25052520
return [self.contextMenuProvider contextMenuConfigurationWith:cellData from:cell session:self.dataSource.mxSession];
25062521
}
25072522

@@ -2511,14 +2526,22 @@ - (void)tableView:(UITableView *)tableView willPerformPreviewActionForMenuWithCo
25112526

25122527
if (!roomId)
25132528
{
2529+
self.recentsUpdateEnabled = YES;
25142530
return;
25152531
}
25162532

25172533
[animator addCompletion:^{
2534+
self.recentsUpdateEnabled = YES;
25182535
[self showRoomWithRoomId:roomId inMatrixSession:self.mainSession];
25192536
}];
25202537
}
25212538

2539+
- (UITargetedPreview *)tableView:(UITableView *)tableView previewForDismissingContextMenuWithConfiguration:(UIContextMenuConfiguration *)configuration API_AVAILABLE(ios(13.0))
2540+
{
2541+
self.recentsUpdateEnabled = YES;
2542+
return nil;
2543+
}
2544+
25222545
#pragma mark - RoomContextActionServiceDelegate
25232546

25242547
- (void)roomContextActionServiceDidJoinRoom:(id<RoomContextActionServiceProtocol>)service

Riot/Modules/Home/HomeViewController.m

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -902,6 +902,7 @@ - (UIContextMenuConfiguration *)collectionView:(UICollectionView *)collectionVie
902902
return nil;
903903
}
904904

905+
self.recentsUpdateEnabled = NO;
905906
return [self.contextMenuProvider contextMenuConfigurationWith:cellData from:cell session:self.dataSource.mxSession];
906907
}
907908

@@ -911,12 +912,20 @@ - (void)collectionView:(UICollectionView *)collectionView willPerformPreviewActi
911912

912913
if (!roomId)
913914
{
915+
self.recentsUpdateEnabled = YES;
914916
return;
915917
}
916918

917919
[animator addCompletion:^{
920+
self.recentsUpdateEnabled = YES;
918921
[self showRoomWithRoomId:roomId inMatrixSession:self.mainSession];
919922
}];
920923
}
921924

925+
- (UITargetedPreview *)collectionView:(UICollectionView *)collectionView previewForDismissingContextMenuWithConfiguration:(UIContextMenuConfiguration *)configuration API_AVAILABLE(ios(13.0))
926+
{
927+
self.recentsUpdateEnabled = YES;
928+
return nil;
929+
}
930+
922931
@end

Riot/Modules/MatrixKit/Categories/NSBundle+MXKLanguage.m

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616

1717
#import "NSBundle+MXKLanguage.h"
18+
#import "GeneratedInterface-Swift.h"
1819

1920
#import <objc/runtime.h>
2021

@@ -55,37 +56,37 @@ + (void)mxk_setLanguage:(NSString *)language
5556
[self setupMXKLanguageBundle];
5657

5758
// [NSBundle localizedStringForKey] calls will be redirected to the bundle corresponding
58-
// to "language"
59-
objc_setAssociatedObject([NSBundle mainBundle],
60-
&_bundle, language ? [NSBundle bundleWithPath:[[NSBundle mainBundle] pathForResource:language ofType:@"lproj"]] : nil,
59+
// to "language". `lprojBundleFor` loads this from the main app bundle as we might be running in an extension.
60+
objc_setAssociatedObject(NSBundle.app,
61+
&_bundle, language ? [NSBundle lprojBundleFor:language] : nil,
6162
OBJC_ASSOCIATION_RETAIN_NONATOMIC);
6263

63-
objc_setAssociatedObject([NSBundle mainBundle],
64+
objc_setAssociatedObject(NSBundle.app,
6465
&_language, language,
6566
OBJC_ASSOCIATION_RETAIN_NONATOMIC);
6667
}
6768

6869
+ (NSString *)mxk_language
6970
{
70-
return objc_getAssociatedObject([NSBundle mainBundle], &_language);
71+
return objc_getAssociatedObject(NSBundle.app, &_language);
7172
}
7273

7374
+ (void)mxk_setFallbackLanguage:(NSString *)language
7475
{
7576
[self setupMXKLanguageBundle];
7677

77-
objc_setAssociatedObject([NSBundle mainBundle],
78-
&_fallbackBundle, language ? [NSBundle bundleWithPath:[[NSBundle mainBundle] pathForResource:language ofType:@"lproj"]] : nil,
78+
objc_setAssociatedObject(NSBundle.app,
79+
&_fallbackBundle, language ? [NSBundle lprojBundleFor:language] : nil,
7980
OBJC_ASSOCIATION_RETAIN_NONATOMIC);
8081

81-
objc_setAssociatedObject([NSBundle mainBundle],
82+
objc_setAssociatedObject(NSBundle.app,
8283
&_fallbackLanguage, language,
8384
OBJC_ASSOCIATION_RETAIN_NONATOMIC);
8485
}
8586

8687
+ (NSString *)mxk_fallbackLanguage
8788
{
88-
return objc_getAssociatedObject([NSBundle mainBundle], &_fallbackLanguage);
89+
return objc_getAssociatedObject(NSBundle.app, &_fallbackLanguage);
8990
}
9091

9192
#pragma mark - Private methods
@@ -96,7 +97,7 @@ + (void)setupMXKLanguageBundle
9697
dispatch_once(&onceToken, ^{
9798

9899
// Use MXKLanguageBundle as the [NSBundle mainBundle] class
99-
object_setClass([NSBundle mainBundle], [MXKLanguageBundle class]);
100+
object_setClass(NSBundle.app, MXKLanguageBundle.class);
100101
});
101102
}
102103

Riot/Modules/MatrixKit/Controllers/MXKRecentListViewController.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ limitations under the License.
5959
The fake top view displayed in case of vertical bounce.
6060
*/
6161
__weak UIView *topview;
62+
63+
/**
64+
`isRefreshNeeded` is set to `YES` if an update of the datasource has been triggered but the UI has not been updated.
65+
It's set to `NO` after a refresh of the UI.
66+
*/
67+
BOOL isRefreshNeeded;
6268
}
6369

6470
@property (weak, nonatomic) IBOutlet UISearchBar *recentsSearchBar;
@@ -83,6 +89,11 @@ limitations under the License.
8389
*/
8490
@property (nonatomic) BOOL enableBarButtonSearch;
8591

92+
/**
93+
Enabled or disabled the UI update after recents syncs. Default YES.
94+
*/
95+
@property (nonatomic, getter=isRecentsUpdateEnabled) BOOL recentsUpdateEnabled;
96+
8697
#pragma mark - Class methods
8798

8899
/**

Riot/Modules/MatrixKit/Controllers/MXKRecentListViewController.m

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ - (void)finalizeInit
8383
{
8484
[super finalizeInit];
8585

86+
_recentsUpdateEnabled = YES;
8687
_enableBarButtonSearch = YES;
8788
}
8889

@@ -169,6 +170,8 @@ - (void)viewWillAppear:(BOOL)animated
169170

170171
// Observe the server sync
171172
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onSyncNotification) name:kMXSessionDidSyncNotification object:nil];
173+
174+
self.recentsUpdateEnabled = YES;
172175
}
173176

174177
- (void)viewWillDisappear:(BOOL)animated
@@ -319,6 +322,10 @@ - (void)displayList:(MXKRecentsDataSource *)listDataSource
319322

320323
- (void)refreshRecentsTable
321324
{
325+
if (!self.recentsUpdateEnabled) return;
326+
327+
isRefreshNeeded = NO;
328+
322329
// For now, do a simple full reload
323330
[self.recentsTableView reloadData];
324331
}
@@ -330,6 +337,16 @@ - (void)hideSearchBar:(BOOL)hidden
330337
[self.view setNeedsUpdateConstraints];
331338
}
332339

340+
- (void)setRecentsUpdateEnabled:(BOOL)activeUpdate
341+
{
342+
_recentsUpdateEnabled = activeUpdate;
343+
344+
if (_recentsUpdateEnabled && isRefreshNeeded)
345+
{
346+
[self refreshRecentsTable];
347+
}
348+
}
349+
333350
#pragma mark - Action
334351

335352
- (IBAction)search:(id)sender
@@ -385,6 +402,12 @@ - (NSString *)cellReuseIdentifierForCellData:(MXKCellData*)cellData
385402

386403
- (void)dataSource:(MXKDataSource *)dataSource didCellChange:(id)changes
387404
{
405+
if (!_recentsUpdateEnabled)
406+
{
407+
isRefreshNeeded = YES;
408+
return;
409+
}
410+
388411
// For now, do a simple full reload
389412
[self refreshRecentsTable];
390413
}

0 commit comments

Comments
 (0)