Skip to content

Commit

Permalink
Merge branch 'release/1.8.12/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
pixlwave committed Apr 6, 2022
2 parents 1e99e19 + 6213bae commit 6d1cf01
Show file tree
Hide file tree
Showing 11 changed files with 144 additions and 43 deletions.
8 changes: 8 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## Changes in 1.8.12 (2022-04-06)

🐛 Bugfixes

- RecentsViewController: Room context preview dismissed unexpectedly ([#5992](https://github.com/vector-im/element-ios/issues/5992))
- 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))


## Changes in 1.8.11 (2022-04-05)

✨ Features
Expand Down
4 changes: 2 additions & 2 deletions Config/AppVersion.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
//

// Version
MARKETING_VERSION = 1.8.11
CURRENT_PROJECT_VERSION = 1.8.11
MARKETING_VERSION = 1.8.12
CURRENT_PROJECT_VERSION = 1.8.12
10 changes: 9 additions & 1 deletion Riot/Categories/Bundle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import Foundation
public extension Bundle {
/// Returns the real app bundle.
/// Can also be used in app extensions.
static var app: Bundle {
@objc static var app: Bundle {
let bundle = main
if bundle.bundleURL.pathExtension == "appex" {
// Peel off two directory levels - MY_APP.app/PlugIns/MY_APP_EXTENSION.appex
Expand All @@ -31,6 +31,14 @@ public extension Bundle {
return bundle
}

/// Get an lproj language bundle from the main app bundle.
/// - Parameter language: The language to try to load.
/// - Returns: The lproj bundle if found otherwise `nil`.
@objc static func lprojBundle(for language: String) -> Bundle? {
guard let lprojURL = Bundle.app.url(forResource: language, withExtension: "lproj") else { return nil }
return Bundle(url: lprojURL)
}

/// Whether or not the bundle is the RiotShareExtension.
var isShareExtension: Bool {
bundleURL.lastPathComponent.contains("RiotShareExtension.appex")
Expand Down
3 changes: 1 addition & 2 deletions Riot/Generated/Strings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8006,7 +8006,7 @@ public class VectorL10n: NSObject {

extension VectorL10n {
static func tr(_ table: String, _ key: String, _ args: CVarArg...) -> String {
let format = NSLocalizedString(key, tableName: table, bundle: Bundle(for: BundleToken.self), comment: "")
let format = NSLocalizedString(key, tableName: table, bundle: Bundle.app, comment: "")
let locale: Locale
if let providedLocale = LocaleProvider.locale {
locale = providedLocale
Expand All @@ -8018,4 +8018,3 @@ extension VectorL10n {
}
}

private final class BundleToken {}
23 changes: 23 additions & 0 deletions Riot/Modules/Common/Recents/RecentsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,14 @@ - (void)viewDidLayoutSubviews

- (void)refreshRecentsTable
{
if (!self.recentsUpdateEnabled)
{
isRefreshNeeded = NO;
return;
}

isRefreshNeeded = NO;

// Refresh the tabBar icon badges
[[AppDelegate theDelegate].masterTabBarController refreshTabBarBadges];

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

- (void)dataSource:(MXKDataSource *)dataSource didCellChange:(id)changes
{
if (!self.recentsUpdateEnabled)
{
[super dataSource:dataSource didCellChange:changes];
return;
}

BOOL cellReloaded = NO;
if ([changes isKindOfClass:RecentsSectionUpdate.class])
{
Expand Down Expand Up @@ -2502,6 +2516,7 @@ - (UIContextMenuConfiguration *)tableView:(UITableView *)tableView contextMenuCo
return nil;
}

self.recentsUpdateEnabled = NO;
return [self.contextMenuProvider contextMenuConfigurationWith:cellData from:cell session:self.dataSource.mxSession];
}

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

if (!roomId)
{
self.recentsUpdateEnabled = YES;
return;
}

[animator addCompletion:^{
self.recentsUpdateEnabled = YES;
[self showRoomWithRoomId:roomId inMatrixSession:self.mainSession];
}];
}

- (UITargetedPreview *)tableView:(UITableView *)tableView previewForDismissingContextMenuWithConfiguration:(UIContextMenuConfiguration *)configuration API_AVAILABLE(ios(13.0))
{
self.recentsUpdateEnabled = YES;
return nil;
}

#pragma mark - RoomContextActionServiceDelegate

- (void)roomContextActionServiceDidJoinRoom:(id<RoomContextActionServiceProtocol>)service
Expand Down
9 changes: 9 additions & 0 deletions Riot/Modules/Home/HomeViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -902,6 +902,7 @@ - (UIContextMenuConfiguration *)collectionView:(UICollectionView *)collectionVie
return nil;
}

self.recentsUpdateEnabled = NO;
return [self.contextMenuProvider contextMenuConfigurationWith:cellData from:cell session:self.dataSource.mxSession];
}

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

if (!roomId)
{
self.recentsUpdateEnabled = YES;
return;
}

[animator addCompletion:^{
self.recentsUpdateEnabled = YES;
[self showRoomWithRoomId:roomId inMatrixSession:self.mainSession];
}];
}

- (UITargetedPreview *)collectionView:(UICollectionView *)collectionView previewForDismissingContextMenuWithConfiguration:(UIContextMenuConfiguration *)configuration API_AVAILABLE(ios(13.0))
{
self.recentsUpdateEnabled = YES;
return nil;
}

@end
21 changes: 11 additions & 10 deletions Riot/Modules/MatrixKit/Categories/NSBundle+MXKLanguage.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

#import "NSBundle+MXKLanguage.h"
#import "GeneratedInterface-Swift.h"

#import <objc/runtime.h>

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

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

objc_setAssociatedObject([NSBundle mainBundle],
objc_setAssociatedObject(NSBundle.app,
&_language, language,
OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}

+ (NSString *)mxk_language
{
return objc_getAssociatedObject([NSBundle mainBundle], &_language);
return objc_getAssociatedObject(NSBundle.app, &_language);
}

+ (void)mxk_setFallbackLanguage:(NSString *)language
{
[self setupMXKLanguageBundle];

objc_setAssociatedObject([NSBundle mainBundle],
&_fallbackBundle, language ? [NSBundle bundleWithPath:[[NSBundle mainBundle] pathForResource:language ofType:@"lproj"]] : nil,
objc_setAssociatedObject(NSBundle.app,
&_fallbackBundle, language ? [NSBundle lprojBundleFor:language] : nil,
OBJC_ASSOCIATION_RETAIN_NONATOMIC);

objc_setAssociatedObject([NSBundle mainBundle],
objc_setAssociatedObject(NSBundle.app,
&_fallbackLanguage, language,
OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}

+ (NSString *)mxk_fallbackLanguage
{
return objc_getAssociatedObject([NSBundle mainBundle], &_fallbackLanguage);
return objc_getAssociatedObject(NSBundle.app, &_fallbackLanguage);
}

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

// Use MXKLanguageBundle as the [NSBundle mainBundle] class
object_setClass([NSBundle mainBundle], [MXKLanguageBundle class]);
object_setClass(NSBundle.app, MXKLanguageBundle.class);
});
}

Expand Down
11 changes: 11 additions & 0 deletions Riot/Modules/MatrixKit/Controllers/MXKRecentListViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ limitations under the License.
The fake top view displayed in case of vertical bounce.
*/
__weak UIView *topview;

/**
`isRefreshNeeded` is set to `YES` if an update of the datasource has been triggered but the UI has not been updated.
It's set to `NO` after a refresh of the UI.
*/
BOOL isRefreshNeeded;
}

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

/**
Enabled or disabled the UI update after recents syncs. Default YES.
*/
@property (nonatomic, getter=isRecentsUpdateEnabled) BOOL recentsUpdateEnabled;

#pragma mark - Class methods

/**
Expand Down
23 changes: 23 additions & 0 deletions Riot/Modules/MatrixKit/Controllers/MXKRecentListViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ - (void)finalizeInit
{
[super finalizeInit];

_recentsUpdateEnabled = YES;
_enableBarButtonSearch = YES;
}

Expand Down Expand Up @@ -169,6 +170,8 @@ - (void)viewWillAppear:(BOOL)animated

// Observe the server sync
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onSyncNotification) name:kMXSessionDidSyncNotification object:nil];

self.recentsUpdateEnabled = YES;
}

- (void)viewWillDisappear:(BOOL)animated
Expand Down Expand Up @@ -319,6 +322,10 @@ - (void)displayList:(MXKRecentsDataSource *)listDataSource

- (void)refreshRecentsTable
{
if (!self.recentsUpdateEnabled) return;

isRefreshNeeded = NO;

// For now, do a simple full reload
[self.recentsTableView reloadData];
}
Expand All @@ -330,6 +337,16 @@ - (void)hideSearchBar:(BOOL)hidden
[self.view setNeedsUpdateConstraints];
}

- (void)setRecentsUpdateEnabled:(BOOL)activeUpdate
{
_recentsUpdateEnabled = activeUpdate;

if (_recentsUpdateEnabled && isRefreshNeeded)
{
[self refreshRecentsTable];
}
}

#pragma mark - Action

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

- (void)dataSource:(MXKDataSource *)dataSource didCellChange:(id)changes
{
if (!_recentsUpdateEnabled)
{
isRefreshNeeded = YES;
return;
}

// For now, do a simple full reload
[self refreshRecentsTable];
}
Expand Down
Loading

0 comments on commit 6d1cf01

Please sign in to comment.