application icon indicating copy to clipboard operation
application copied to clipboard

MessagesStorage & RequestStorage

Open MartinMajor opened this issue 11 years ago • 24 comments

This pull request separates flash messages into new service MessagesStorage. It also separates store & restore requests into new service RequestStorage. This new service redirects to original URL when restoring old requests.

MartinMajor avatar Apr 20 '14 02:04 MartinMajor

See also related pull request.

MartinMajor avatar Apr 20 '14 02:04 MartinMajor

Awesome! :+1:

hrach avatar Apr 20 '14 08:04 hrach

Great work! :)

stepansvoboda avatar Apr 20 '14 10:04 stepansvoboda

What is the reason for refactoring two different functionalities in one pull?

mishak87 avatar Apr 20 '14 11:04 mishak87

@mishak87 you should take a breath, calm down and think before you write.

fprochazka avatar Apr 20 '14 12:04 fprochazka

@mishak87 @rostenkowski I have already did a review, you are just copying my notes ;)

hrach avatar Apr 20 '14 12:04 hrach

@mishak87 My goal was to separate RequestStorage and provide redirect to original URL when restoreRequest() is called. But RequestStorage has dependency to flash messages so I had to separate them too.

MartinMajor avatar Apr 20 '14 12:04 MartinMajor

@fprochazka Next time write what I did wrong instead of how you think I should handle myself which is extremely rude.

@MartinMajor Such note would be very helpful in the description ~~along with review from @hrach~~.

As Majkl always reminds people don't force push pulls it messes up comments.

mishak87 avatar Apr 20 '14 13:04 mishak87

@mishak87 I think it's extremely rude to push people into doing work that is not neccesary. For example telling them to separate code to two pullrequests if it's already separated by commits.

FYI pullrequests are meant to be forcepushed in.

fprochazka avatar Apr 20 '14 17:04 fprochazka

@fprochazka Nobody is rushing anyone. I asked a simple question and got an answer. Your little tantrums are OT.

What pull requests mean or not I do consult only The Spaghetti Monster.

mishak87 avatar Apr 21 '14 19:04 mishak87

I've renamed MessagesStorage -> MessageStorage and MessagesStorage::isOpended() -> MessageStorage::hasMessages()

MartinMajor avatar May 31 '14 09:05 MartinMajor

I don't know what problem is with FLASH_KEY in IMessageStorage. IMessageStorage stores flash messages into some storage but its key has to be transfered in URL no matter what storage is used. Other services (e.g. RequestStorage) has to be able get this key, so this constant should be IMHO in IMessageStorage.

FLASH_KEY in Presenter has to be for back compatibility.

MartinMajor avatar May 31 '14 09:05 MartinMajor

@MartinMajor Name of the key is related to routing or presenter. Storage should not know about it.

mishak87 avatar May 31 '14 21:05 mishak87

@mishak87 And where would you put that constant? In Presenter? So all services, that need to use it (e.g. RequestStorage) had to have dependency on Presenter?

MartinMajor avatar Jun 01 '14 20:06 MartinMajor

I think it is great. The only little bit confusing thing is mixing terms message vs flash.

dg avatar Jun 02 '14 07:06 dg

@MartinMajor To sum it up. I think this is step forward. But there is still missing what I would call bluntly layer for embedding non presenter related parameters into url (set of interfaces or events). If you try separating flash message functionality into own package you would see the issues.

IMO flash message is Web 1.0 concept and should be done away completely. It does not help with UX issues and offers only limiting functionality to user. User can't react on it. Some Nette projects modify its behavior, because they are lazy to write its own component. Or just for translating text. Final solution should enable creation of more featured replacements. Icons, links, buttons, templating etc.

mishak87 avatar Jun 02 '14 14:06 mishak87

Now I think that MessageStorage is over-engeneered :-) Because it is not about "messages" and it's doubled $id in setId() and setMessage() is confusing and very closely tighted to components in presenter.

In fact, MessageStorage is just storage for any values. It can become FlashStorage, ~~but the fact that it exists only few seconds is not its main purpose (in addition it must be set manually via setExpiration). The main purpose is to be "attached" to the single tab in browser. So it is BrowserTabStorage.~~

And ~~BrowserTabStorage~~ FlashStorage, without all "message stuff", is universal storage, so it can be implemented in nette/http and used in application this way https://github.com/dg/nette-application/commit/9a59074920c925d378b8bd910009537f11d2aed4.

This pull should therefore look like https://github.com/dg/nette-application/commit/0147db46c025079654c914159f67b03bd5715c5e

dg avatar Jun 03 '14 11:06 dg

Another thing: is it really needed to have REQUEST_KEY and FLASH_KEY in URL together?

dg avatar Jun 03 '14 11:06 dg

@dg: ok, as I wrote above, my main goal was to refactor RequestStorage, so I have nothing against TabStorage. REQUEST_KEY & FLASH_KEY: When request is restored (and REQUEST_KEY is used) there can be generated new flash message (e.g. "login successful") so there are both this keys in URL at the same time (if that is what have you asked for).

MartinMajor avatar Jun 03 '14 22:06 MartinMajor

I think we get rid of _rid, it should work with one identifier ;)

dg avatar Jul 01 '14 15:07 dg

@MartinMajor what do you think about this solution?

  • https://github.com/nette/http/pull/5
  • https://github.com/nette/application/pull/17

dg avatar Jul 01 '14 22:07 dg

I'll look at it till the end of this week (hopefully).

MartinMajor avatar Jul 02 '14 07:07 MartinMajor

@dg I like your solution and it works great.

MartinMajor avatar Jul 04 '14 16:07 MartinMajor

:+1:

f3l1x avatar Aug 09 '15 10:08 f3l1x