I copied some code from committerSearch.js.rb.

Could this code be shared somehow?

If not, does it need to use a different localStorage identifier?

On 16 November 2017 at 00:58,  <s...@apache.org> wrote:
> This is an automated email from the ASF dual-hosted git repository.
>
> sebb pushed a commit to branch master
> in repository https://gitbox.apache.org/repos/asf/whimsy.git
>
>
> The following commit(s) were added to refs/heads/master by this push:
>      new d63324c  Look up emails to see if they are known
> d63324c is described below
>
> commit d63324c73cb91c476a3533df3fb25d18c56cf94d
> Author: Sebb <s...@apache.org>
> AuthorDate: Thu Nov 16 00:57:57 2017 +0000
>
>     Look up emails to see if they are known
> ---
>  www/roster/views/pmc/pmc.js.rb | 47 
> +++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 46 insertions(+), 1 deletion(-)
>
> diff --git a/www/roster/views/pmc/pmc.js.rb b/www/roster/views/pmc/pmc.js.rb
> index aab724d..ec7705e 100644
> --- a/www/roster/views/pmc/pmc.js.rb
> +++ b/www/roster/views/pmc/pmc.js.rb
> @@ -5,6 +5,7 @@
>  class PMCMembers < Vue
>    def initialize
>      @committee = {}
> +    @committers = []
>    end
>
>    def render
> @@ -46,7 +47,32 @@ class PMCMembers < Vue
>          _br
>          _ul {
>            for mail in @@committee.unknownSubs
> -            _li @@committee.unknownSubs[mail]
> +            addr = @@committee.unknownSubs[mail]
> +            who = nil
> +            @committers.each do |person|
> +              if person.mail.any? {|mail| mail.include? addr}
> +                who = person
> +              end
> +            end
> +            _li {
> +              _ addr
> +              _ ' '
> +              if who
> +                if who.member
> +                  _b {
> +                    _ who.name
> +                    _ ' '
> +                    _a who.id, href: "committer/#{who.id}"
> +                  }
> +                else
> +                  _ who.name
> +                  _ ' '
> +                  _a who.id, href: "committer/#{who.id}"
> +                end
> +              else
> +                _ '(email not found)'
> +              end
> +            }
>            end
>          }
>        }
> @@ -55,6 +81,25 @@ class PMCMembers < Vue
>
>    def mounted()
>      jQuery('.table', $el).stupidtable()
> +    # start with (possibly stale) data from local storage when available
> +    # TODO does this need to use a different item name?
> +    # Or how to share the code with committerSearch.js.rb?
> +    ls_committers = localStorage.getItem('roster-committers')
> +    if ls_committers
> +      @committers = JSON.parse(ls_committers)
> +    end
> +
> +    # load fresh data from the server
> +    Polyfill.require(%w(Promise fetch)) do
> +      fetch('committer/index.json', credentials: 'include').then {|response|
> +        response.json().then do |committers|
> +          @committers = committers
> +          localStorage.setItem('roster-committers', @committers.inspect)
> +        end
> +      }.catch {|error|
> +        console.log error
> +      }
> +    end
>    end
>
>    def roster
>
> --
> To stop receiving notification emails like this one, please contact
> ['"comm...@whimsical.apache.org" <comm...@whimsical.apache.org>'].

Reply via email to