Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove PushKit #3268

Merged
merged 27 commits into from
May 29, 2020
Merged

Remove PushKit #3268

merged 27 commits into from
May 29, 2020

Conversation

ismailgulek
Copy link
Contributor

@ismailgulek ismailgulek commented May 22, 2020

Fix #2714

@ismailgulek ismailgulek marked this pull request as ready for review May 25, 2020 10:11
Copy link
Member

@manuroe manuroe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have not finished the review yet. Will come back to it in 2h.

- (void)didReceiveRemoteNotification:(NSDictionary *)userInfo
fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
{
// NSLog(@"[PushNotificationService][Push] didReceiveRemoteNotification: applicationState: %tu - payload: %@", [UIApplication sharedApplication].applicationState, userInfo);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we still log the call of this function?
It could be useful for sanity check.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Bundle.mxk_customizeLocalizedStringTableName("Vector")

if isatty(STDERR_FILENO) == 0 {
// MXLogger.setSubLogName("nse")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To fix. Logs are useful

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

}

theUserAccount.mxSession.event(withEventId: theEventId, inRoom: theRoomId, success: { [weak self] (event) in
guard let strongSelf = self else {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use the following swift 4.x:

Suggested change
guard let strongSelf = self else {
guard let self = self else {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

return
}

guard let theEvent = event else {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
guard let theEvent = event else {
guard let event = event else {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

}

func processEvent(_ event: MXEvent) {
if let content = originalContent, let theUserAccount = userAccount {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could use userAcccount = self.userAccount to unwrap the value.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

// Modify the notification content here...
guard let newContent = notificationContent else {
// remove
UNUserNotificationCenter.current().removePendingNotificationRequests(withIdentifiers: [self.requestIdentifier!])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should always unwrap optionals for long term sanity.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

{
NSLog(@"[PushNotificationService][Push] didReceiveRemoteNotification: applicationState: %tu - payload: %@", [UIApplication sharedApplication].applicationState, userInfo);
//
// // Display local notifications only when the app is running in background.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we remove commented code?
This is to avoid to keep dead comments for years. Specially when there is no "comment" for the commented section.
We will be able to retrieve this piece of code in git if we need it one day.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

CALLS_ENABLE_CALLKIT_INDEX = 0,
CALLS_CALLKIT_DESCRIPTION_INDEX,
CALLS_ENABLE_STUN_SERVER_FALLBACK_INDEX,
//CALLS_ENABLE_CALLKIT_INDEX = 0,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can clear this commented piece of code as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Riot/Utils/Constants.swift Outdated Show resolved Hide resolved
func fetchEvent() {
guard let content = originalContent, let userAccount = self.userAccount else {
// there is something wrong, do not change the content
NSLog("[NotificationService] Fallback case 4")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we have more detail in the log for future debugging?
Like:

Suggested change
NSLog("[NotificationService] Fallback case 4")
NSLog("[NotificationService] fetchEvent: Fallback case 4. There is something wrong, do not change the content")

This worths for all Fallback case X :)

I do not understand the order for X :/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're totally right. It was easy for debugging on development. Changing them all.

}

guard let event = event else {
return
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we call self.fallbackToOriginalContent() here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it will be more clear.

}

// should show decrypted content in notification
guard event.clear == nil else {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
guard event.clear == nil else {
if event.clear {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

RiotNSE/NotificationService.swift Outdated Show resolved Hide resolved
}

func launchBackgroundSync() {
guard let userAccount = userAccount else { return }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we call self.fallbackToOriginalContent() here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also adding this

RiotNSE/NotificationService.swift Show resolved Hide resolved
RiotNSE/NotificationService.swift Outdated Show resolved Hide resolved
Copy link
Member

@manuroe manuroe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using a new implementation NSEMemoryStore is really smart 👍

store = MXFileStore(credentials: userAccount.mxCredentials)
if let userAccount = MXKAccountManager.shared()?.activeAccounts.first {
store = NSEMemoryStore(withCredentials: userAccount.mxCredentials)
store.open(with: userAccount.mxCredentials, onComplete: nil, failure: nil)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can be removed. It is called by MXSession.setStore()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's right. Removing.

RiotNSE/NotificationService.swift Show resolved Hide resolved
room.state({ (roomState: MXRoomState!) in

// initialize a temporary file store, just to load the room state
let fileStore = MXFileStore(credentials: session.credentials)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not using the existing NSEMemoryStore and implement stateOfRoom there?

Copy link
Contributor Author

@ismailgulek ismailgulek May 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, totally makes sense. Updating.

Signed-off-by: ismailgulek <[email protected]>
Signed-off-by: ismailgulek <[email protected]>
Copy link
Member

@manuroe manuroe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good for me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants